WO2018166258A1 - Data processing method and apparatus for nand flash, and nand flash - Google Patents

Data processing method and apparatus for nand flash, and nand flash Download PDF

Info

Publication number
WO2018166258A1
WO2018166258A1 PCT/CN2017/116828 CN2017116828W WO2018166258A1 WO 2018166258 A1 WO2018166258 A1 WO 2018166258A1 CN 2017116828 W CN2017116828 W CN 2017116828W WO 2018166258 A1 WO2018166258 A1 WO 2018166258A1
Authority
WO
WIPO (PCT)
Prior art keywords
data packet
nand flash
latest
mapping table
physical
Prior art date
Application number
PCT/CN2017/116828
Other languages
French (fr)
Chinese (zh)
Inventor
朱细平
Original Assignee
深圳市江波龙电子有限公司
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 深圳市江波龙电子有限公司 filed Critical 深圳市江波龙电子有限公司
Publication of WO2018166258A1 publication Critical patent/WO2018166258A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/061Improving I/O performance
    • G06F3/0611Improving I/O performance in relation to response time
    • 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/0655Vertical data movement, i.e. input-output transfer; data movement between one or more hosts and one or more storage devices
    • 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]

Definitions

  • the present application relates to the field of storage media technologies, and in particular, to a Nand flash data processing method and apparatus, and a Nand flash.
  • Nand flash memory Nand flash memory
  • FTL Flash Translation Layer
  • the embodiment of the present application provides Nand
  • the data processing method and device of the flash and a Nand flash can quickly complete the access processing operation of the Nand flash on a small amount of data, greatly reducing the storage burden when the Nand flash processes a small amount of data, and prolonging the service life of the Nand flash.
  • a Nand is provided a flash data processing method applied to the Nand flash block specified in the Nand flash;
  • the Nand Flash data processing methods include:
  • mapping table Obtaining, in the latest data packet, a mapping table, where the mapping table records a mapping relationship between a logical number and a physical number of each data packet stored in the current Nand flash block;
  • mapping table Adding the established mapping relationship to the mapping table to generate a new mapping table
  • the new data packet is written into a physical page corresponding to the latest available physical number.
  • a Nand is provided The data processing method of the flash is applied to the Nand flash block specified in the Nand flash, where the Nand flash block stores a data packet in a preset format;
  • the Nand Flash data processing methods include:
  • mapping table Obtaining, in the latest data packet, a mapping table, where the mapping table records a mapping relationship between a logical number and a physical number of each data packet stored in the current Nand flash block;
  • the determined physical number corresponds to the data packet in the physical page.
  • a Nand is provided The data processing method of the flash is applied to the Nand flash block specified in the Nand flash, where the Nand flash block stores a data packet in a preset format;
  • the Nand Flash data processing methods include:
  • mapping table Obtaining, in the latest data packet, a mapping table, where the mapping table records a mapping relationship between a logical number and a physical number of each data packet stored in the current Nand flash block;
  • mapping table Updating the physical number corresponding to the logical number in the mapping table to the latest available physical number, to obtain a new mapping table, where the latest available physical number is the physical number corresponding to the latest available physical page in the current Nand flash block. ;
  • the new data packet is written into a physical page corresponding to the latest available physical number.
  • a Nand is provided The data processing method of the flash is applied to the Nand flash block specified in the Nand flash, where the Nand flash block stores a data packet in a preset format;
  • the Nand Flash data processing methods include:
  • mapping table Obtaining, in the latest data packet, a mapping table, where the mapping table records a mapping relationship between a logical number and a physical number of each data packet stored in the current Nand flash block;
  • mapping table And deleting a mapping relationship between the logical number and the corresponding physical number from the mapping table, to obtain a new mapping table
  • the new data packet is written into a physical page corresponding to the latest available physical number, and the latest available physical number is a physical number corresponding to the latest available physical page in the current Nand flash block.
  • a fifth aspect provides a Nand flash block processing method based on the Nand flash data processing method, wherein the Nand flash is provided with a block circulation pool composed of two or more specified Nand flash blocks;
  • the Nand flash block processing method further includes: before reading the latest data packet of the current Nand flash block according to the latest packet index number:
  • the block changing operation specifically includes the following steps:
  • a Nand is provided a flash data processing device applied to the Nand flash block specified in the Nand flash;
  • the Nand The flash data processing device includes:
  • a first latest data packet reading module configured to: if the data volume of the data to be written is less than a preset threshold, read the latest data packet of the current Nand flash block according to the latest data packet index number, where the latest data packet index The number is a physical number corresponding to a physical page storing the latest written data packet in the current Nand flash block;
  • a first mapping table obtaining module configured to acquire a mapping table in the latest data packet, where the mapping table records a mapping relationship between a logical number and a physical number of each data packet stored in the current Nand flash block;
  • mapping relationship establishing module configured to establish a mapping relationship between the logical number assigned to the data to be written and the latest available physical number, where the latest available physical number is the latest available physical page in the current Nand flash block Physical number
  • a first new mapping table generating module configured to add the established mapping relationship to the mapping table to generate a new mapping table
  • a first new data packet generating module configured to generate a new data packet according to the new mapping table and the to-be-written data
  • the first writing module is configured to write the new data packet into a physical page corresponding to the latest available physical number.
  • a Nand is provided A flash data processing device is applied to the Nand flash block specified in the Nand flash, where the Nand flash block stores a data packet in a preset format;
  • the Nand The flash data processing device includes:
  • a read instruction acquisition module configured to acquire a read instruction of the data packet to be read
  • a first packet number determining module configured to determine a logical number of the to-be-read data packet according to the read instruction
  • a second latest packet reading module configured to read the latest data packet of the current Nand flash block according to the latest data packet index number, where the latest data packet index number is the latest data packet stored in the current Nand flash block The physical number corresponding to the physical page;
  • a second mapping table obtaining module configured to acquire a mapping table in the latest data packet, where the mapping table records a mapping relationship between a logical number and a physical number of each data packet stored in the current Nand flash block;
  • a first physical number determining module configured to determine, according to the logical number and the mapping table, a physical number of the to-be-read data packet
  • a first data packet reading unit configured to read the determined data packet in the physical page corresponding to the physical number.
  • a Nand is provided A flash data processing device is applied to the Nand flash block specified in the Nand flash, where the Nand flash block stores a data packet in a preset format;
  • the Nand The flash data processing device includes:
  • Modifying an instruction obtaining module configured to acquire a modification instruction of the data packet to be modified and data to be modified;
  • a second packet number determining module configured to determine a logical number of the to-be-modified data packet according to the modification instruction
  • a third latest packet reading module configured to read the latest data packet of the current Nand flash block according to the latest data packet index number, where the latest data packet index number is the latest data packet stored in the current Nand flash block The physical number corresponding to the physical page;
  • a third mapping table obtaining module configured to acquire a mapping table in the latest data packet, where the mapping table records a mapping relationship between a logical number and a physical number of each data packet stored in the current Nand flash block;
  • a second physical number determining module configured to determine a physical number of the to-be-modified data packet according to the logical number and the mapping table
  • a second data packet reading unit configured to read the determined data packet in the physical page corresponding to the physical number
  • a second new mapping table generating module configured to update a physical number corresponding to the logical number in the mapping table to a latest available physical number, to obtain a new mapping table, where the latest available physical number is the current Nand flash block The physical number corresponding to the latest available physical page;
  • a data modification module configured to modify data in the read data packet by using the data to be modified
  • a second new data packet generating module configured to generate a new data packet according to the modified data and the new mapping table
  • a second writing module configured to write the new data packet into a physical page corresponding to the latest available physical number.
  • a Nand is provided A flash data processing device is applied to the Nand flash block specified in the Nand flash, where the Nand flash block stores a data packet in a preset format;
  • the Nand The flash data processing device includes:
  • Deleting an instruction acquisition module configured to acquire a deletion instruction of the data packet to be deleted
  • a third packet number determining module configured to determine a logical number of the to-be-deleted data packet according to the deleting instruction
  • a fourth latest packet reading module configured to read the latest data packet of the current Nand flash block according to the latest data packet index number, where the latest data packet index number is the latest data packet stored in the current Nand flash block The physical number corresponding to the physical page;
  • a fourth mapping table obtaining module configured to acquire a mapping table in the latest data packet, where the mapping table records a mapping relationship between a logical number and a physical number of each data packet stored in the current Nand flash block;
  • a third new mapping table generating module configured to delete a mapping relationship between the logical number and a corresponding physical number from the mapping table, to obtain a new mapping table
  • a third new data packet generating module configured to generate a new data packet according to the new mapping table
  • a third write module configured to write the new data packet into a physical page corresponding to a latest available physical number, where the latest available physical number is a physical number corresponding to the latest available physical page in the current Nand flash block .
  • a Nand is provided Flash, including the above Nand flash data processing device.
  • an electronic device comprising: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor The instructions are executed by the at least one processor to enable the at least one processor to perform the method as described above.
  • a non-transitory computer readable storage medium is stored, the computer readable storage medium storing computer executable instructions for causing a computer to perform the method as described above.
  • a computer program product comprising a computer program stored on a non-transitory computer readable storage medium, the computer program comprising program instructions, wherein the program instructions are When executed, the computer is caused to perform the method as described above.
  • the embodiments of the present application have the following advantages:
  • the Nand flash can access the small amount of data quickly. , greatly reducing the storage burden of Nand flash processing a small amount of data, extending the life of Nand flash.
  • FIG. 1 is a schematic diagram of a data structure of a data packet in an embodiment of the present application
  • FIG. 3 is a flowchart of a process of writing a data packet in an embodiment of the present application
  • FIG. 5 is a flowchart of a process of reading a data packet in an embodiment of the present application
  • FIG. 6 is a flowchart of a process of modifying a data packet in an embodiment of the present application.
  • FIG. 7 is a flowchart of a process of deleting a data packet in an embodiment of the present application.
  • FIG. 8 is a structural diagram of Embodiment 2 of a data processing apparatus for Nand flash in the embodiment of the present application;
  • FIG. 9 is a structural diagram of Embodiment 3 of a data processing apparatus for Nand flash in the embodiment of the present application.
  • Embodiment 4 is a structural diagram of Embodiment 4 of a data processing apparatus for Nand flash in the embodiment of the present application;
  • Embodiment 11 is a structural diagram of Embodiment 5 of a data processing apparatus for Nand flash in the embodiment of the present application;
  • FIG. 12 is a structural diagram of Embodiment 6 of a Nand flash block processing apparatus according to an embodiment of the present application.
  • FIG. 13 is a schematic structural diagram of hardware of an eighth embodiment of an electronic device according to an embodiment of the present application.
  • the embodiment of the present application provides Nand
  • the data processing method and device of the flash and a Nand flash are used to solve the problem that the existing Nand flash easily increases the storage load and reduces the access processing speed when storing a small amount of data.
  • Embodiment 1 is a diagrammatic representation of Embodiment 1:
  • This embodiment provides a Nand
  • the flash data processing method is an easy storage method for the Nand flash feature.
  • the method mainly adopts the first-level mapping method of logical number and physical number, and is a simple storage method for performing Nand flash page reading, Nand flash page writing, Nand flash page editing, and entire Nand flash block erasing in units of data packets.
  • Nand flash a non-volatile memory device
  • Nand flash page A storage unit of Nand flash.
  • the size of a Nand flash page can be 4KBYTE, 8KBYTE, 16KBYTE, and so on.
  • Nand flash block A storage unit of Nand flash, containing dozens of Nand flash pages to hundreds of Nand flash pages;
  • a small amount of data refers to less than one Nand flash page of data
  • a packet of a preset format consisting of a packet header and a small amount of data. If the packet has less than one physical page of data, the packet may be filled with a random number.
  • the packet header may be composed of a packet identification code, a logical number to a physical number mapping table, packet information, and user information.
  • the mapping table is required for the data packet in this embodiment, and a small amount of data, packet information, user information, and the like may be selectively added according to actual use requirements;
  • Logical number The number of the packet access.
  • the read command sent by the upper computer includes the logical number corresponding to the data packet;
  • Physical number the serial number of the physical page of the actual storage packet, that is, the serial number of the Nand flash physical page in the Nand flash block;
  • the latest packet index number refers to the physical number of the physical page that stores the most recently written packet
  • Data that is not frequently written data that is rarely modified after writing
  • Packet identification code A string of data with certain rules to obtain the latest packet index number.
  • the package identification code is mainly used to determine whether the Nand flash page has been used, thereby determining the latest packet index number.
  • the logical number and the physical number are natural sequence sequences arranged from 0, and the mapping relationship between the logical number mapping and the physical number is established, and the corresponding mapping table, that is, the logic, can be generated.
  • Number to the physical number mapping table is a first-level mapping method, and the updating of the mapping table refers to the updating of the mapping relationship between the logical number and the physical number.
  • Nand flash data processing method provided by this embodiment has the following features:
  • mapping table occurs in the operations of writing, modifying, and deleting data packets.
  • Package_index indicates the latest packet index number
  • Max_phy_number indicates the maximum physical number
  • Phy_num indicates the physical number
  • LN_ind indicates the logical number
  • TB_size indicates the size of the mapping table.
  • this embodiment first introduces the acquisition process of the "latest packet index number". As shown in Figure 2, the following steps can be included:
  • step 204 determining whether there is a packet identification code in the read data packet, and if so, executing step 205, if not, executing step 206;
  • the writing process of the data packet may include the following steps:
  • step 302. Determine whether the data amount of the data to be written is less than a preset threshold. If yes, execute step 303. If not, perform a write operation on the data to be written by using a general storage method.
  • step 306 Determine the package_index as a physical number of the new data packet, and add a mapping relationship between the assigned logical number and the physical number of the new data packet to the end of the mapping table to generate a new mapping table. Then performing step 308;
  • the foregoing "preset threshold" may be data of one Nandflash page, one Nand
  • the size of the flash page can be 4KBYTE, 8KBYTE, 16KBYTE, and the like. It can be understood that the data processing method of the Nand flash provided by this embodiment is more suitable for processing a small amount of data. Therefore, when the data to be written is not less than the preset threshold, it can be considered that the current data to be written is not a small amount of data, so that the general storage method can be used for the writing process.
  • the general storage method referred to herein refers to a data storage method related to Nand flash in the prior art, such as the FTL method.
  • step 303 the method for obtaining the package_index has been described in detail in the above content, and details are not described herein again.
  • the physical page corresponding to the package_index does not have the package identification code, indicating that the physical page is empty. Therefore, the package_index is the latest available physical number, and the package_index is directly determined as the physical number of the new data packet, and the physical number is established.
  • the mapping relationship between the physical number of the new data packet and the assigned logical number, and the mapping relationship is recorded in the mapping table. It can be understood that if there is no mapping table, a new mapping table can be created.
  • the assigned logical number may be automatically allocated by the Nand flash for the new data packet, or may be determined or allocated by an instruction or request for writing the data to be written. The embodiment does not limit this.
  • step 307 when the current Nand flash block is not a new block, since the physical page corresponding to the Package_index is occupied by data, when the physical page is allocated for the new data packet, the physical page of the Package_index+1 position should be selected, that is, Package_index+ 1 is the latest available physical number.
  • the package information and the user information may be determined according to the source of the data to be written, or may be updated by the obtained package information and user information in the latest data packet, or may be adopted.
  • the two pieces of information are written in the default manner, which is not limited in this embodiment.
  • step 303 it may be determined whether the package_index of the current Nand flash block is equal to Max_phy_number. If yes, it indicates that the current Nand flash block is full, and the block changing operation needs to be performed, and the next Nand flash in the block circulation pool is executed. The block is determined to be the current Nand flash block, and then proceeds to step 303; if not, step 303 is performed.
  • the block changing operation will be described in detail below.
  • the process of the block changing operation may include the following steps:
  • step 404 determine whether LN_ind is less than TB_size, and if so, proceed to step 405, and if not, proceed to step 408;
  • the data of the next Nand flash block is first erased, so that the original invalid physical page in the next Nand flash block can be cleared, so that it becomes a new block. Then, all the valid data packets in the current Nand flash block are written one by one according to the mapping table of the latest data packet to the next Nand flash block, and the mapping relationship of each data packet is modified separately. After the data is relocated, the next Nand flash block can be determined as the current Nand flash block to complete the block swap operation.
  • the data packet that has been written in the Nand flash block can be read according to the read command sent by the host computer.
  • the method includes the following steps:
  • the determined physical number corresponds to a data packet in a physical page.
  • the read command can be issued by the host computer connected to the Nand flash.
  • the logical instruction number may be included in the read instruction, and the data packet information for determining the logical number may be included, and then the logical number is determined according to the data packet information, which is not limited thereto.
  • the mapping relationship in the mapping table the physical number of the data packet to be read corresponding to the logical number may be determined. It can be understood that, due to the writing mechanism of the data packet in this embodiment, the mapping table in the latest data packet includes the mapping relationship between the logical number and the physical number of all the data packets in the current Nand flash block.
  • the required data packet that is, the data packet to be read, can be directly read according to the physical number.
  • the data packet can then be sent to the host computer or other device that issued the read command.
  • the host computer or other device can perform the modification operation by issuing the modification instruction to the current Nand flash block.
  • the modification process of the data packet may include the following steps:
  • the determined physical number corresponds to a data packet in a physical page.
  • the modification instruction can be issued by the host computer connected to the Nand flash. Moreover, while obtaining the modification instruction, the data to be modified by the data packet, that is, the data to be updated, may be acquired.
  • the modified instruction may include the logical number, or may include the data packet information for determining the logical number, and then determine the logical number according to the data packet information, which is not limited thereto.
  • the mapping relationship in the mapping table the physical number of the to-be-modified data packet corresponding to the logical number may be determined. It can be understood that, due to the writing mechanism of the data packet in this embodiment, the mapping table in the latest data packet includes the mapping relationship between the logical number and the physical number of all the data packets in the current Nand flash block.
  • the required data packet that is, the data packet to be modified, can be directly read according to the physical number.
  • step 606 in the present embodiment, when the data packet is modified, the data is not directly modified on the original physical page, but the updated data is written into the empty physical page in a written manner. Therefore, using Package_index+1 as the physical number of the packet is equivalent to allocating the latest physical page to the modified packet.
  • step 607 after reading the data packet to be modified, the data in the data packet is modified using the data to be modified to implement data update.
  • a new data packet is generated based on the modified data and the new mapping table, as well as the package information and the user information.
  • the package information and the user information may be determined according to the modification instruction, or may be updated by the package information and the user information in the read data packet to be modified, or the two information may be written in a default manner. In this regard, the embodiment is not limited.
  • the new data packet may be written into a physical page corresponding to its physical number, that is, a physical page corresponding to Package_index+1.
  • the packet modification is complete.
  • step 603 it may be determined whether the package_index of the current Nand flash block is equal to Max_phy_number. If yes, it indicates that the current Nand flash block is full, and the block changing operation needs to be performed, and the next Nand flash in the block circulation pool is executed. The block is determined to be the current Nand flash block, and then step 603 is performed; if not, step 603 is performed.
  • the host computer or other device can cause the current Nand flash block to perform the delete operation by issuing a delete instruction.
  • the process of deleting a data packet may include the following steps:
  • the delete command can be issued by the host computer connected to the Nand flash.
  • the logical instruction number may be included in the deletion instruction, and the data packet information for determining the logical number may be included, and then the logical number is determined according to the data packet information, which is not limited thereto.
  • step 704 it can be understood that when deleting a data packet in the Nand flash block, only the mapping relationship between the logical number and the physical number of the data packet needs to be deleted, because when the mapping relationship is deleted, for the Nand flash For devices other than the ones, the deleted packets are unknown. And because of the current Nand The determination of all the data packets in the flash block is queried through the mapping table in the latest data packet. Therefore, after the mapping relationship needs to be deleted, a new mapping table is generated and step 705 is executed to generate a new data packet.
  • step 705 it can be seen that the generated new data packet does not have valid data available therein, and its function is to record a new mapping table and allow the new mapping table to be read when needed.
  • step 706 after generating a new data packet, the new data packet is written into the latest physical page, that is, the physical page corresponding to Package_index+1, and the data packet deletion operation is completed.
  • step 703 it may be determined whether the package_index of the current Nand flash block is equal to Max_phy_number, and if so, it indicates that the current Nand flash block is full, and the block changing operation needs to be performed, and the next Nand flash in the block circulation pool is executed.
  • the block is determined to be the current Nand flash block, and then step 703 is performed; if not, step 703 is performed.
  • the above operations of writing, reading, modifying, deleting, changing blocks, and the like may be performed on the Nand flash, and only one or more operations may be performed separately, for example, for a certain Nand.
  • the flash performs a write operation, and then performs a modify operation and a delete operation. It should be understandable that in Nand Any combination of the above operations of writing, reading, modifying, deleting, changing blocks, and the like can be performed on the flash, and the order of execution between these operations is not limited.
  • Embodiment 2 is a diagrammatic representation of Embodiment 1:
  • This embodiment also provides a Nand A flash data processing device is applied to the Nand flash block specified in the Nand flash, and mainly performs data writing processing of the Nand flash block.
  • the data processing apparatus of the Nand flash includes:
  • Writing data acquisition module 801 configured to acquire data to be written
  • the first latest packet reading module 802 is configured to: if the data volume of the data to be written is less than a preset threshold, read the current Nand according to the latest packet index number.
  • the first mapping table obtaining module 803 is configured to obtain a mapping table in the latest data packet, where the mapping table records a mapping relationship between a logical number and a physical number of each data packet stored in the current Nand flash block. ;
  • the mapping relationship establishing module 804 is configured to establish a mapping relationship between the logical number assigned to the data to be written and the latest available physical number, where the latest available physical number is the latest available physical page in the current Nand flash block. Corresponding physical number;
  • a first new mapping table generating module 805, configured to add the established mapping relationship to the mapping table, to generate a new mapping table
  • a first new data packet generating module 806, configured to generate a new data packet according to the new mapping table and the to-be-written data
  • the first writing module 807 is configured to write the new data packet into a physical page corresponding to the latest available physical number.
  • Embodiment 3 is a diagrammatic representation of Embodiment 3
  • This embodiment also provides a Nand A flash data processing device is applied to a Nand flash block specified in the Nand flash, and the Nand flash block stores a data packet in a preset format.
  • the data processing device of the Nand flash mainly performs data reading processing of the Nand flash block.
  • the data processing apparatus of the Nand flash includes:
  • the read instruction obtaining module 901 is configured to acquire a read instruction of the data packet to be read;
  • a first packet number determining module 902 configured to determine a logical number of the to-be-read data packet according to the read instruction
  • the second latest packet reading module 903 is configured to read the latest data packet of the current Nand flash block according to the latest data packet index number, where the latest data packet index number is the latest data written in the current Nand flash block.
  • the second mapping table obtaining module 904 is configured to obtain a mapping table in the latest data packet, where the mapping table records a mapping relationship between a logical number and a physical number of each data packet stored in the current Nand flash block. ;
  • the first physical number determining module 905 is configured to determine, according to the logical number and the mapping table, a physical number of the data packet to be read;
  • the first packet reading unit 906 is configured to read the determined data packet in the physical page corresponding to the physical number.
  • Embodiment 4 is a diagrammatic representation of Embodiment 4:
  • This embodiment also provides a Nand A flash data processing device is applied to a Nand flash block specified in the Nand flash, and the Nand flash block stores a data packet in a preset format.
  • the data processing device of the Nand flash mainly performs data modification processing of the Nand flash block.
  • the data processing apparatus of the Nand flash includes:
  • the instruction fetching module 1001 is configured to obtain a modification instruction of the data packet to be modified and data to be modified;
  • a second packet number determining module 1002 configured to determine a logical number of the to-be-modified data packet according to the modification instruction
  • the third latest packet reading module 1003 is configured to read the latest data packet of the current Nand flash block according to the latest data packet index number, where the latest data packet index number is the latest data written in the current Nand flash block.
  • the third mapping table obtaining module 1004 is configured to obtain a mapping table in the latest data packet, where the mapping table records a mapping relationship between a logical number and a physical number of each data packet stored in the current Nand flash block. ;
  • a second physical number determining module 1005, configured to determine, according to the logical number and the mapping table, a physical number of the to-be-modified data packet;
  • the second packet reading unit 1006 is configured to read the determined data packet in the physical page corresponding to the physical number
  • the second new mapping table generating module 1007 is configured to update the physical number corresponding to the logical number in the mapping table to the latest available physical number, to obtain a new mapping table, where the latest available physical number is the current Nand flash The physical number corresponding to the latest available physical page in the block;
  • a data modification module 1008 configured to modify data in the read data packet by using the data to be modified
  • a second new data packet generating module 1009 configured to generate a new data packet according to the modified data and the new mapping table
  • the second writing module 1010 is configured to write the new data packet into a physical page corresponding to the latest available physical number.
  • Embodiment 5 is a diagrammatic representation of Embodiment 5:
  • This embodiment also provides a Nand A flash data processing device is applied to a Nand flash block specified in the Nand flash, and the Nand flash block stores a data packet in a preset format.
  • the data processing device of the Nand flash mainly performs data reading processing of the Nand flash block.
  • the data processing apparatus of the Nand flash includes:
  • the deletion instruction obtaining module 111 is configured to acquire a deletion instruction of the data packet to be deleted
  • a third packet number determining module 112 configured to determine a logical number of the to-be-deleted data packet according to the deleting instruction
  • the fourth latest packet reading module 113 is configured to read the latest data packet of the current Nand flash block according to the latest data packet index number, where the latest data packet index number is the latest data written in the current Nand flash block.
  • the fourth mapping table obtaining module 114 is configured to obtain a mapping table in the latest data packet, where the mapping table records a mapping relationship between a logical number and a physical number of each data packet stored in the current Nand flash block. ;
  • a third new mapping table generating module 115 configured to delete a mapping relationship between the logical number and a corresponding physical number from the mapping table, to obtain a new mapping table
  • a third new data packet generating module 116 configured to generate a new data packet according to the new mapping table
  • a third writing module 117 configured to write the new data packet into a physical page corresponding to a latest available physical number, where the latest available physical number is a physical corresponding to the latest available physical page in the current Nand flash block. number.
  • the embodiment further provides a Nand flash block processing apparatus which is further improved on the basis of the data processing apparatus of any of the Nand flash described in the foregoing embodiments of FIG. 8, FIG. 10 or FIG.
  • the Nand flash is provided with a block circulation pool composed of two or more specified Nand flash blocks.
  • the Nand flash block processing apparatus further includes:
  • the full load judging module 121 is configured to determine whether the current Nand flash block is full
  • the first triggering module 122 is configured to trigger the first latest packet reading module 802, the third latest packet reading module 1003, or the fourth latest packet if the determination result of the full load determining module 121 is negative. Reading module 113;
  • the second triggering module 123 is configured to trigger the block changing module 124 if the determination result of the full load determining module 121 is YES, and then trigger the first latest packet reading module 802 and the third latest packet reading module. 1003 or fourth latest packet reading module 113;
  • the block changing module 124 may specifically include the following units:
  • a block erasing unit 1241 configured to erase a next Nand flash block in the block cycle pool
  • the latest packet reading unit 1242 is configured to read the latest data packet of the current Nand flash block according to the latest packet index number
  • mapping table obtaining unit 1243 configured to acquire a mapping table in the latest data packet
  • An initializing unit 1244 configured to initialize a value of the first logical number
  • the packet shifting unit 1245 is configured to sequentially read each data packet in the current Nand flash block according to the mapping table by adjusting the value of the first logical number, and sequentially read the read each data packet. Write to the next Nand a flash block until each data packet in the current Nand flash block is written to the next Nand flash block;
  • the current block determining unit 1246 is configured to determine the next Nand flash block as the current Nand flash block.
  • This embodiment also provides a Nand A flash, which includes the data processing apparatus of any of the Nand flashes described in the embodiments of FIG. 8 to FIG. 11, and/or includes any of the Nand flash block processing apparatuses described in the corresponding embodiment of FIG.
  • the Nand flash may also include the data processing apparatus and the Nand flash block processing apparatus of all forms of Nand flash described in the above embodiments of FIGS. 8 to 12.
  • FIG. 13 is a schematic diagram of a hardware structure of an electronic device 13 according to an embodiment of the present disclosure. As shown in FIG. 13, the electronic device 13 includes:
  • processors 131 and memory 132 one processor 131 is exemplified in FIG.
  • the processor 131 and the memory 132 may be connected by a bus or other means, as exemplified by a bus connection in FIG.
  • the memory 132 is a non-volatile computer readable storage medium, and can be used for storing a non-volatile software program, a non-volatile computer-executable program, and a module, as in the Nand flash data processing method in the embodiment of the present application.
  • Program instructions/modules eg, the modules shown in Figure 8.
  • the processor 131 executes various functional applications and data processing of the electronic device by executing non-volatile software programs, instructions, and modules stored in the memory 132, that is, the data processing method of the Nand flash of the above-described method embodiment.
  • the memory 132 may include a storage program area and an storage data area, wherein the storage program area may store an operating system, an application required for at least one function; the storage data area may store data created according to the use of the data processing device of the Nand flash, and the like. .
  • memory 132 can include high speed random access memory, and can also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device.
  • the memory 132 can optionally include a memory remotely located relative to the processor 131 that can be connected to the data processing device of the Nand flash via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
  • the one or more modules are stored in the memory 132, and when executed by the one or more processors 131, perform a data processing method of the Nand flash in any of the above method embodiments, for example, performing the above description.
  • the method steps in FIG. 2, the method steps in FIG. 3, the method steps in FIG. 4, the method steps in FIG. 5, the method steps in FIG. 6, the method steps in FIG. 7, and the modules and figures in FIG. The functions of the modules in 9, the modules in Figure 10, the modules in Figure 11, and the modules in Figure 12.
  • the electronic device of the embodiment of the present application exists in various forms, such as a flash memory device or the like.
  • Embodiments of the present application provide a non-transitory computer readable storage medium storing computer-executable instructions that are executed by one or more processors, for example, to perform the above
  • the embodiment of the present application provides a computer program product, the computer program product comprising a computer program stored on a non-transitory computer readable storage medium, the computer program comprising program instructions, when the program instructions are executed by a computer
  • the data processing method of the Nand flash in any of the above method embodiments is performed, for example, the method steps in FIG. 2, the method steps in FIG. 3, the method steps in FIG. 4, and FIG. 5 are performed.
  • the disclosed system, apparatus, and method may be implemented in other manners.
  • the device embodiments described above are merely illustrative.
  • the division of the unit is only a logical function division.
  • there may be another division manner for example, multiple units or components may be combined or Can be integrated into another system, or some features can be ignored or not executed.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, and may be in an electrical, mechanical or other form.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
  • each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
  • the above integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
  • the integrated unit if implemented in the form of a software functional unit and sold or used as a standalone product, may be stored in a computer readable storage medium.
  • a computer readable storage medium A number of instructions are included to cause a computer device (which may be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present application.
  • the foregoing storage medium includes: a U disk, a mobile hard disk, a read only memory (ROM, Read-Only) Memory), random access memory (RAM, Random)
  • ROM Read Only memory
  • RAM Random

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Techniques For Improving Reliability Of Storages (AREA)

Abstract

Disclosed are a data processing method and apparatus for an NAND flash, and an NAND flash, which are used for solving the problems of an additional storage burden being easily added and the access processing speed being reduced when an existing NAND flash stores a small amount of data. The method of the embodiments of the present application comprises: acquiring data to be written; if the data amount of the data to be written is less than a pre-set threshold value, reading the latest data packet of a current NAND flash block according to an index number of the latest data packet, wherein the index number of the latest data packet is a physical number corresponding to a physical page, in the current NAND flash block, where the most recently written data packet is stored; acquiring a mapping table in the latest data packet, wherein a mapping relationship between a logical number of each data packet stored in the current NAND flash block and the physical number is recorded in the mapping table; establishing a new mapping relationship; adding the established mapping relationship into the mapping table to generate a new mapping table; generating a new data packet according to the new mapping table and the data to be written; and writing the new data packet into a physical page corresponding to the newest available physical number.

Description

Nand flash的数据处理方法、装置和一种Nand flashNand flash data processing method, device and a Nand flash 技术领域Technical field
本申请涉及存储介质技术领域,尤其涉及Nand flash的数据处理方法、装置和一种Nand flash。The present application relates to the field of storage media technologies, and in particular, to a Nand flash data processing method and apparatus, and a Nand flash.
背景技术Background technique
现有Nand flash(Nand型闪存)存储针对Nand flash特性采用了FTL(Flash Translation Layer,闪存转换层)方法,其一般包括以下处理机制:Existing Nand The flash (Nand flash memory) storage adopts the FTL (Flash Translation Layer) method for the Nand flash feature, which generally includes the following processing mechanisms:
1)建立坏Nand flash块表;1) Create a bad Nand flash block table;
2)建立Nand flash块映射表;2) Establish a Nand flash block mapping table;
3)建立Nand flash页映射表;3) Create a Nand flash page mapping table;
4)采用平衡磨损算法提高整体使用寿命;4) Using a balanced wear algorithm to improve the overall service life;
5)垃圾回收机制;5) Garbage collection mechanism;
6)重读机制。6) Rereading mechanism.
通过上述系列复杂的算法保证整体使用寿命和快速使用存储数据。Through the above series of complex algorithms to ensure the overall life and fast use of stored data.
然而,当Nand flash用来存储一些数据量少(例如少于Nand flash的一个物理页)且又不经常写的数据时,采用上述复杂的处理机制不仅增加额外的存储负担,降低了数据的存取处理速度,而且减少了Nand flash的使用寿命。However, when Nand When flash is used to store data with a small amount of data (for example, less than one physical page of Nand flash) and is not frequently written, the above complex processing mechanism not only increases the additional storage burden, but also reduces the access processing speed of the data. And reduce the life of the Nand flash.
发明内容Summary of the invention
本申请实施例提供了Nand flash的数据处理方法、装置和一种Nand flash,能够快速完成Nand flash对少量数据的存取处理操作,大大减轻Nand flash处理少量数据时的存储负担,延长Nand flash的使用寿命。The embodiment of the present application provides Nand The data processing method and device of the flash and a Nand flash can quickly complete the access processing operation of the Nand flash on a small amount of data, greatly reducing the storage burden when the Nand flash processes a small amount of data, and prolonging the service life of the Nand flash.
第一方面,提供了一种Nand flash的数据处理方法,应用于在所述Nand flash中指定的Nand flash块;In the first aspect, a Nand is provided a flash data processing method applied to the Nand flash block specified in the Nand flash;
所述Nand flash的数据处理方法包括:The Nand Flash data processing methods include:
获取待写入数据;Get the data to be written;
若所述待写入数据的数据量小于预设阈值,则根据最新数据包索引号读取当前Nand flash块的最新数据包,所述最新数据包索引号为所述当前Nand flash块中存储最新写入的数据包的物理页对应的物理号;If the data volume of the data to be written is less than a preset threshold, reading the latest data packet of the current Nand flash block according to the latest data packet index number, where the latest data packet index number is the latest in the current Nand flash block. The physical number corresponding to the physical page of the written packet;
获取所述最新数据包中的映射表,所述映射表记录有所述当前Nand flash块中存储的各个数据包的逻辑号与物理号之间的映射关系;Obtaining, in the latest data packet, a mapping table, where the mapping table records a mapping relationship between a logical number and a physical number of each data packet stored in the current Nand flash block;
建立分配给所述待写入数据的逻辑号与最新可用物理号之间的映射关系,所述最新可用物理号为所述当前Nand flash块中最新的可用物理页对应的物理号;Establishing a mapping relationship between the logical number assigned to the data to be written and the latest available physical number, where the latest available physical number is a physical number corresponding to the latest available physical page in the current Nand flash block;
将建立的所述映射关系添加至所述映射表中,生成新的映射表;Adding the established mapping relationship to the mapping table to generate a new mapping table;
根据所述新的映射表和所述待写入数据生成新的数据包;Generating a new data packet according to the new mapping table and the to-be-written data;
将所述新的数据包写入所述最新可用物理号对应的物理页内。The new data packet is written into a physical page corresponding to the latest available physical number.
第二方面,提供了一种Nand flash的数据处理方法,应用于在所述Nand flash中指定的Nand flash块,所述Nand flash块中存储有预设格式的数据包;In the second aspect, a Nand is provided The data processing method of the flash is applied to the Nand flash block specified in the Nand flash, where the Nand flash block stores a data packet in a preset format;
所述Nand flash的数据处理方法包括:The Nand Flash data processing methods include:
获取待读取数据包的读取指令;Obtaining a read instruction of the data packet to be read;
根据所述读取指令确定所述待读取数据包的逻辑号;Determining, according to the read instruction, a logical number of the data packet to be read;
根据最新数据包索引号读取当前Nand flash块的最新数据包,所述最新数据包索引号为所述当前Nand flash块中存储最新写入的数据包的物理页对应的物理号;Reading the latest data packet of the current Nand flash block according to the latest data packet index number, where the latest data packet index number is a physical number corresponding to the physical page of the current Nand flash block storing the newly written data packet;
获取所述最新数据包中的映射表,所述映射表记录有所述当前Nand flash块中存储的各个数据包的逻辑号与物理号之间的映射关系;Obtaining, in the latest data packet, a mapping table, where the mapping table records a mapping relationship between a logical number and a physical number of each data packet stored in the current Nand flash block;
根据所述逻辑号和所述映射表确定所述待读取数据包的物理号;Determining, according to the logical number and the mapping table, a physical number of the data packet to be read;
读取确定的所述物理号对应物理页中的数据包。The determined physical number corresponds to the data packet in the physical page.
第三方面,提供了一种Nand flash的数据处理方法,应用于在所述Nand flash中指定的Nand flash块,所述Nand flash块中存储有预设格式的数据包;In a third aspect, a Nand is provided The data processing method of the flash is applied to the Nand flash block specified in the Nand flash, where the Nand flash block stores a data packet in a preset format;
所述Nand flash的数据处理方法包括:The Nand Flash data processing methods include:
获取待修改数据包的修改指令以及待修改的数据;Obtaining a modification instruction of the data packet to be modified and data to be modified;
根据所述修改指令确定所述待修改数据包的逻辑号;Determining, according to the modification instruction, a logical number of the data packet to be modified;
根据最新数据包索引号读取当前Nand flash块的最新数据包,所述最新数据包索引号为所述当前Nand flash块中存储最新写入的数据包的物理页对应的物理号;Reading the latest data packet of the current Nand flash block according to the latest data packet index number, where the latest data packet index number is a physical number corresponding to the physical page of the current Nand flash block storing the newly written data packet;
获取所述最新数据包中的映射表,所述映射表记录有所述当前Nand flash块中存储的各个数据包的逻辑号与物理号之间的映射关系;Obtaining, in the latest data packet, a mapping table, where the mapping table records a mapping relationship between a logical number and a physical number of each data packet stored in the current Nand flash block;
根据所述逻辑号和所述映射表确定所述待修改数据包的物理号;Determining, according to the logical number and the mapping table, a physical number of the to-be-modified data packet;
读取确定的所述物理号对应物理页中的数据包;Reading the determined physical number corresponding to the data packet in the physical page;
将所述映射表中所述逻辑号对应的物理号更新为最新可用物理号,得到新的映射表,所述最新可用物理号为所述当前Nand flash块中最新的可用物理页对应的物理号;Updating the physical number corresponding to the logical number in the mapping table to the latest available physical number, to obtain a new mapping table, where the latest available physical number is the physical number corresponding to the latest available physical page in the current Nand flash block. ;
采用所述待修改的数据修改读取的所述数据包中的数据;Modifying the data in the read data packet by using the data to be modified;
根据修改后的数据和所述新的映射表生成新的数据包;Generating a new data packet according to the modified data and the new mapping table;
将所述新的数据包写入所述最新可用物理号对应的物理页内。The new data packet is written into a physical page corresponding to the latest available physical number.
第四方面,提供了一种Nand flash的数据处理方法,应用于在所述Nand flash中指定的Nand flash块,所述Nand flash块中存储有预设格式的数据包;In a fourth aspect, a Nand is provided The data processing method of the flash is applied to the Nand flash block specified in the Nand flash, where the Nand flash block stores a data packet in a preset format;
所述Nand flash的数据处理方法包括:The Nand Flash data processing methods include:
获取待删除数据包的删除指令;Obtaining a delete instruction of the data packet to be deleted;
根据所述删除指令确定所述待删除数据包的逻辑号;Determining, according to the deleting instruction, a logical number of the to-be-deleted data packet;
根据最新数据包索引号读取当前Nand flash块的最新数据包,所述最新数据包索引号为所述当前Nand flash块中存储最新写入的数据包的物理页对应的物理号;Reading the latest data packet of the current Nand flash block according to the latest data packet index number, where the latest data packet index number is a physical number corresponding to the physical page of the current Nand flash block storing the newly written data packet;
获取所述最新数据包中的映射表,所述映射表记录有所述当前Nand flash块中存储的各个数据包的逻辑号与物理号之间的映射关系;Obtaining, in the latest data packet, a mapping table, where the mapping table records a mapping relationship between a logical number and a physical number of each data packet stored in the current Nand flash block;
从所述映射表中删除所述逻辑号与对应的物理号之间的映射关系,得到新的映射表;And deleting a mapping relationship between the logical number and the corresponding physical number from the mapping table, to obtain a new mapping table;
根据所述新的映射表生成新的数据包;Generating a new data packet according to the new mapping table;
将所述新的数据包写入最新可用物理号对应的物理页内,所述最新可用物理号为所述当前Nand flash块中最新的可用物理页对应的物理号。The new data packet is written into a physical page corresponding to the latest available physical number, and the latest available physical number is a physical number corresponding to the latest available physical page in the current Nand flash block.
第五方面,提供了一种基于上述的Nand flash的数据处理方法的Nand flash块处理方法,所述Nand flash中设有由两个以上指定的Nand flash块组成的块循环池;A fifth aspect provides a Nand flash block processing method based on the Nand flash data processing method, wherein the Nand flash is provided with a block circulation pool composed of two or more specified Nand flash blocks;
在根据最新数据包索引号读取当前Nand flash块的最新数据包之前,所述Nand flash块处理方法还包括:The Nand flash block processing method further includes: before reading the latest data packet of the current Nand flash block according to the latest packet index number:
判断所述当前Nand flash块是否已满;Judging the current Nand Whether the flash block is full;
若所述当前Nand flash块未满,则执行根据最新数据包索引号读取当前Nand flash块的最新数据包的步骤;If the current Nand If the flash block is not full, the step of reading the latest data packet of the current Nand flash block according to the latest packet index number is performed;
若所述当前Nand flash块已满,则执行换块操作,然后执行根据最新数据包索引号读取当前Nand flash块的最新数据包的步骤;If the current Nand After the flash block is full, the block changing operation is performed, and then the step of reading the latest data packet of the current Nand flash block according to the latest packet index number is performed;
所述换块操作具体包括以下步骤:The block changing operation specifically includes the following steps:
擦除所述块循环池中的下一个Nand flash块;Erasing the next Nand flash block in the block loop pool;
根据最新数据包索引号读取所述当前Nand flash块的最新数据包;Reading the latest data packet of the current Nand flash block according to the latest packet index number;
获取所述最新数据包中的映射表;Obtaining a mapping table in the latest data packet;
初始化第一逻辑号的值;Initializing the value of the first logical number;
通过调整所述第一逻辑号的值依据所述映射表依次读取所述当前Nand flash块中的各个数据包,并将读取到的所述各个数据包依次写入所述下一个Nand flash块,直到所述当前Nand flash块中的各个数据包均写入至所述下一个Nand flash块;Reading each data packet in the current Nand flash block according to the mapping table by adjusting the value of the first logical number, and sequentially writing the read each data packet to the next Nand a flash block until each data packet in the current Nand flash block is written to the next Nand flash block;
将所述下一个Nand flash块确定为当前Nand flash块。Will the next Nand The flash block is determined to be the current Nand flash block.
第六方面,提供了一种Nand flash的数据处理装置,应用于在所述Nand flash中指定的Nand flash块;In a sixth aspect, a Nand is provided a flash data processing device applied to the Nand flash block specified in the Nand flash;
所述Nand flash的数据处理装置包括:The Nand The flash data processing device includes:
写入数据获取模块,用于获取待写入数据;Writing a data acquisition module for acquiring data to be written;
第一最新数据包读取模块,用于若所述待写入数据的数据量小于预设阈值,则根据最新数据包索引号读取当前Nand flash块的最新数据包,所述最新数据包索引号为所述当前Nand flash块中存储最新写入的数据包的物理页对应的物理号;a first latest data packet reading module, configured to: if the data volume of the data to be written is less than a preset threshold, read the latest data packet of the current Nand flash block according to the latest data packet index number, where the latest data packet index The number is a physical number corresponding to a physical page storing the latest written data packet in the current Nand flash block;
第一映射表获取模块,用于获取所述最新数据包中的映射表,所述映射表记录有所述当前Nand flash块中存储的各个数据包的逻辑号与物理号之间的映射关系;a first mapping table obtaining module, configured to acquire a mapping table in the latest data packet, where the mapping table records a mapping relationship between a logical number and a physical number of each data packet stored in the current Nand flash block;
映射关系建立模块,用于建立分配给所述待写入数据的逻辑号与最新可用物理号之间的映射关系,所述最新可用物理号为所述当前Nand flash块中最新的可用物理页对应的物理号;a mapping relationship establishing module, configured to establish a mapping relationship between the logical number assigned to the data to be written and the latest available physical number, where the latest available physical number is the latest available physical page in the current Nand flash block Physical number
第一新映射表生成模块,用于将建立的所述映射关系添加至所述映射表中,生成新的映射表;a first new mapping table generating module, configured to add the established mapping relationship to the mapping table to generate a new mapping table;
第一新数据包生成模块,用于根据所述新的映射表和所述待写入数据生成新的数据包;a first new data packet generating module, configured to generate a new data packet according to the new mapping table and the to-be-written data;
第一写入模块,用于将所述新的数据包写入所述最新可用物理号对应的物理页内。The first writing module is configured to write the new data packet into a physical page corresponding to the latest available physical number.
第七方面,提供了一种Nand flash的数据处理装置,应用于在所述Nand flash中指定的Nand flash块,所述Nand flash块中存储有预设格式的数据包;In a seventh aspect, a Nand is provided A flash data processing device is applied to the Nand flash block specified in the Nand flash, where the Nand flash block stores a data packet in a preset format;
所述Nand flash的数据处理装置包括:The Nand The flash data processing device includes:
读取指令获取模块,用于获取待读取数据包的读取指令;a read instruction acquisition module, configured to acquire a read instruction of the data packet to be read;
第一包号确定模块,用于根据所述读取指令确定所述待读取数据包的逻辑号;a first packet number determining module, configured to determine a logical number of the to-be-read data packet according to the read instruction;
第二最新数据包读取模块,用于根据最新数据包索引号读取当前Nand flash块的最新数据包,所述最新数据包索引号为所述当前Nand flash块中存储最新写入的数据包的物理页对应的物理号;a second latest packet reading module, configured to read the latest data packet of the current Nand flash block according to the latest data packet index number, where the latest data packet index number is the latest data packet stored in the current Nand flash block The physical number corresponding to the physical page;
第二映射表获取模块,用于获取所述最新数据包中的映射表,所述映射表记录有所述当前Nand flash块中存储的各个数据包的逻辑号与物理号之间的映射关系;a second mapping table obtaining module, configured to acquire a mapping table in the latest data packet, where the mapping table records a mapping relationship between a logical number and a physical number of each data packet stored in the current Nand flash block;
第一物理号确定模块,用于根据所述逻辑号和所述映射表确定所述待读取数据包的物理号;a first physical number determining module, configured to determine, according to the logical number and the mapping table, a physical number of the to-be-read data packet;
第一数据包读取单元,用于读取确定的所述物理号对应物理页中的数据包。And a first data packet reading unit, configured to read the determined data packet in the physical page corresponding to the physical number.
第八方面,提供了一种Nand flash的数据处理装置,应用于在所述Nand flash中指定的Nand flash块,所述Nand flash块中存储有预设格式的数据包;In an eighth aspect, a Nand is provided A flash data processing device is applied to the Nand flash block specified in the Nand flash, where the Nand flash block stores a data packet in a preset format;
所述Nand flash的数据处理装置包括:The Nand The flash data processing device includes:
修改指令获取模块,用于获取待修改数据包的修改指令以及待修改的数据;Modifying an instruction obtaining module, configured to acquire a modification instruction of the data packet to be modified and data to be modified;
第二包号确定模块,用于根据所述修改指令确定所述待修改数据包的逻辑号;a second packet number determining module, configured to determine a logical number of the to-be-modified data packet according to the modification instruction;
第三最新数据包读取模块,用于根据最新数据包索引号读取当前Nand flash块的最新数据包,所述最新数据包索引号为所述当前Nand flash块中存储最新写入的数据包的物理页对应的物理号;a third latest packet reading module, configured to read the latest data packet of the current Nand flash block according to the latest data packet index number, where the latest data packet index number is the latest data packet stored in the current Nand flash block The physical number corresponding to the physical page;
第三映射表获取模块,用于获取所述最新数据包中的映射表,所述映射表记录有所述当前Nand flash块中存储的各个数据包的逻辑号与物理号之间的映射关系;a third mapping table obtaining module, configured to acquire a mapping table in the latest data packet, where the mapping table records a mapping relationship between a logical number and a physical number of each data packet stored in the current Nand flash block;
第二物理号确定模块,用于根据所述逻辑号和所述映射表确定所述待修改数据包的物理号;a second physical number determining module, configured to determine a physical number of the to-be-modified data packet according to the logical number and the mapping table;
第二数据包读取单元,用于读取确定的所述物理号对应物理页中的数据包;a second data packet reading unit, configured to read the determined data packet in the physical page corresponding to the physical number;
第二新映射表生成模块,用于将所述映射表中所述逻辑号对应的物理号更新为最新可用物理号,得到新的映射表,所述最新可用物理号为所述当前Nand flash块中最新的可用物理页对应的物理号;a second new mapping table generating module, configured to update a physical number corresponding to the logical number in the mapping table to a latest available physical number, to obtain a new mapping table, where the latest available physical number is the current Nand flash block The physical number corresponding to the latest available physical page;
数据修改模块,用于采用所述待修改的数据修改读取的所述数据包中的数据;a data modification module, configured to modify data in the read data packet by using the data to be modified;
第二新数据包生成模块,用于根据修改后的数据和所述新的映射表生成新的数据包;a second new data packet generating module, configured to generate a new data packet according to the modified data and the new mapping table;
第二写入模块,用于将所述新的数据包写入所述最新可用物理号对应的物理页内。And a second writing module, configured to write the new data packet into a physical page corresponding to the latest available physical number.
第九方面,提供了一种Nand flash的数据处理装置,应用于在所述Nand flash中指定的Nand flash块,所述Nand flash块中存储有预设格式的数据包;In a ninth aspect, a Nand is provided A flash data processing device is applied to the Nand flash block specified in the Nand flash, where the Nand flash block stores a data packet in a preset format;
所述Nand flash的数据处理装置包括:The Nand The flash data processing device includes:
删除指令获取模块,用于获取待删除数据包的删除指令;Deleting an instruction acquisition module, configured to acquire a deletion instruction of the data packet to be deleted;
第三包号确定模块,用于根据所述删除指令确定所述待删除数据包的逻辑号;a third packet number determining module, configured to determine a logical number of the to-be-deleted data packet according to the deleting instruction;
第四最新数据包读取模块,用于根据最新数据包索引号读取当前Nand flash块的最新数据包,所述最新数据包索引号为所述当前Nand flash块中存储最新写入的数据包的物理页对应的物理号;a fourth latest packet reading module, configured to read the latest data packet of the current Nand flash block according to the latest data packet index number, where the latest data packet index number is the latest data packet stored in the current Nand flash block The physical number corresponding to the physical page;
第四映射表获取模块,用于获取所述最新数据包中的映射表,所述映射表记录有所述当前Nand flash块中存储的各个数据包的逻辑号与物理号之间的映射关系;a fourth mapping table obtaining module, configured to acquire a mapping table in the latest data packet, where the mapping table records a mapping relationship between a logical number and a physical number of each data packet stored in the current Nand flash block;
第三新映射表生成模块,用于从所述映射表中删除所述逻辑号与对应的物理号之间的映射关系,得到新的映射表;a third new mapping table generating module, configured to delete a mapping relationship between the logical number and a corresponding physical number from the mapping table, to obtain a new mapping table;
第三新数据包生成模块,用于根据所述新的映射表生成新的数据包;a third new data packet generating module, configured to generate a new data packet according to the new mapping table;
第三写入模块,用于将所述新的数据包写入最新可用物理号对应的物理页内,所述最新可用物理号为所述当前Nand flash块中最新的可用物理页对应的物理号。a third write module, configured to write the new data packet into a physical page corresponding to a latest available physical number, where the latest available physical number is a physical number corresponding to the latest available physical page in the current Nand flash block .
第十方面,提供了一种Nand flash,包括上述的Nand flash的数据处理装置。In a tenth aspect, a Nand is provided Flash, including the above Nand flash data processing device.
第十一方面,提供了一种电子设备,包括:至少一个处理器;以及与所述至少一个处理器通信连接的存储器;其中,所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行如上所述的方法。In an eleventh aspect, an electronic device is provided, comprising: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor The instructions are executed by the at least one processor to enable the at least one processor to perform the method as described above.
第十二方面,提供了一种非易失性计算机可读存储介质,所述计算机可读存储介质存储有计算机可执行指令,所述计算机可执行指令用于使计算机执行如上所述的方法。In a twelfth aspect, a non-transitory computer readable storage medium is stored, the computer readable storage medium storing computer executable instructions for causing a computer to perform the method as described above.
第十三方面,提供了一种计算机程序产品,所述计算机程序产品包括存储在非易失性计算机可读存储介质上的计算机程序,所述计算机程序包括程序指令,当所述程序指令被计算机执行时,使所述计算机执行如上所述的方法。In a thirteenth aspect, a computer program product is provided, the computer program product comprising a computer program stored on a non-transitory computer readable storage medium, the computer program comprising program instructions, wherein the program instructions are When executed, the computer is caused to perform the method as described above.
从以上技术方案可以看出,本申请实施例具有以下优点:As can be seen from the above technical solutions, the embodiments of the present application have the following advantages:
本申请实施例中,通过将少量的数据打包成预设的数据包格式,并在数据包中建立逻辑号与物理号之间的映射关系,可以快速完成Nand flash对少量数据的存取处理操作,大大减轻了Nand flash处理少量数据时的存储负担,延长Nand flash的使用寿命。In the embodiment of the present application, by packing a small amount of data into a preset data packet format, and establishing a mapping relationship between the logical number and the physical number in the data packet, the Nand flash can access the small amount of data quickly. , greatly reducing the storage burden of Nand flash processing a small amount of data, extending the life of Nand flash.
附图说明DRAWINGS
一个或多个实施例通过与之对应的附图中的图片进行示例性说明,这些示例性说明并不构成对实施例的限定,附图中具有相同参考数字标号的元件表示为类似的元件,除非有特别申明,附图中的图不构成比例限制。The one or more embodiments are exemplified by the accompanying drawings in the accompanying drawings, and FIG. The figures in the drawings do not constitute a scale limitation unless otherwise stated.
图1为本申请实施例中数据包的数据结构示意图;1 is a schematic diagram of a data structure of a data packet in an embodiment of the present application;
图2为本申请实施例中最新数据包索引号获取过程的流程图;2 is a flowchart of an latest data packet index number acquisition process in an embodiment of the present application;
图3为本申请实施例中数据包的写入过程的流程图;3 is a flowchart of a process of writing a data packet in an embodiment of the present application;
图4为本申请实施例中换块操作过程的流程图;4 is a flowchart of a block changing operation process in an embodiment of the present application;
图5为本申请实施例中数据包的读取过程的流程图;FIG. 5 is a flowchart of a process of reading a data packet in an embodiment of the present application;
图6为本申请实施例中数据包的修改过程的流程图;6 is a flowchart of a process of modifying a data packet in an embodiment of the present application;
图7为本申请实施例中数据包的删除过程的流程图;7 is a flowchart of a process of deleting a data packet in an embodiment of the present application;
图8为本申请实施例中Nand flash的数据处理装置实施例二的结构图;FIG. 8 is a structural diagram of Embodiment 2 of a data processing apparatus for Nand flash in the embodiment of the present application;
图9为本申请实施例中Nand flash的数据处理装置实施例三的结构图;FIG. 9 is a structural diagram of Embodiment 3 of a data processing apparatus for Nand flash in the embodiment of the present application;
图10为本申请实施例中Nand flash的数据处理装置实施例四的结构图;10 is a structural diagram of Embodiment 4 of a data processing apparatus for Nand flash in the embodiment of the present application;
图11为本申请实施例中Nand flash的数据处理装置实施例五的结构图;11 is a structural diagram of Embodiment 5 of a data processing apparatus for Nand flash in the embodiment of the present application;
图12为本申请实施例中Nand flash块处理装置实施例六的结构图;FIG. 12 is a structural diagram of Embodiment 6 of a Nand flash block processing apparatus according to an embodiment of the present application;
图13为本申请实施例中电子设备实施例八的硬件结构示意图。FIG. 13 is a schematic structural diagram of hardware of an eighth embodiment of an electronic device according to an embodiment of the present application.
具体实施方式detailed description
本申请实施例提供了Nand flash的数据处理方法、装置和一种Nand flash,用于解决现有Nand flash在存储少量数据时容易增加额外的存储负担,降低存取处理速度的问题。The embodiment of the present application provides Nand The data processing method and device of the flash and a Nand flash are used to solve the problem that the existing Nand flash easily increases the storage load and reduces the access processing speed when storing a small amount of data.
为使得本申请的申请目的、特征、优点能够更加的明显和易懂,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,下面所描述的实施例仅仅是本申请一部分实施例,而非全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其它实施例,都属于本申请保护的范围。In order to make the object, the features and the advantages of the application of the present application more obvious and easy to understand, the technical solutions in the embodiments of the present application will be clearly and completely described in the following with reference to the accompanying drawings in the embodiments of the present application. The described embodiments are only a part of the embodiments of the present application, and not all of them. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments of the present application without departing from the inventive scope are the scope of the present application.
实施例一:Embodiment 1:
本实施例提供了一种Nand flash的数据处理方法是针对Nand flash特性的一种简易存储方法。该方法主要采用逻辑号和物理号的一级映射法,是一种以数据包为单元进行Nand flash页读、Nand flash页写、Nand flash页编辑以及整个Nand flash块擦除的简易存储方法。This embodiment provides a Nand The flash data processing method is an easy storage method for the Nand flash feature. The method mainly adopts the first-level mapping method of logical number and physical number, and is a simple storage method for performing Nand flash page reading, Nand flash page writing, Nand flash page editing, and entire Nand flash block erasing in units of data packets.
首先,在实施例一中,为便于描述,使用如下述语进行描述:First, in the first embodiment, for the convenience of description, description will be made using the following words:
Nand flash:一种非易失的存储器件;Nand flash: a non-volatile memory device;
KBYTE:1024字节;KBYTE: 1024 bytes;
Nand flash页:Nand flash的一种存储单位,一个Nand flash页的大小可以是4KBYTE、8KBYTE、16KBYTE,等等;Nand flash page: A storage unit of Nand flash. The size of a Nand flash page can be 4KBYTE, 8KBYTE, 16KBYTE, and so on.
Nand flash块:Nand flash的一种存储单位,包含有几十个Nand flash页到几百个Nand flash页不等;Nand flash block: A storage unit of Nand flash, containing dozens of Nand flash pages to hundreds of Nand flash pages;
少量数据:指少于一个Nand flash页的数据;A small amount of data: refers to less than one Nand flash page of data;
预设格式的数据包:如图1所示,由包头和少量数据组成,如果数据包少于一个物理页的数据,可以为数据包填充随机数。所述包头可以由包标识码、逻辑号到物理号的映射表、包信息、用户信息组成。其中,对于本实施例中的数据包来说,映射表是必须的,而少量数据、包信息、用户信息等可以根据实际使用需要选择性加入;A packet of a preset format: as shown in FIG. 1, consisting of a packet header and a small amount of data. If the packet has less than one physical page of data, the packet may be filled with a random number. The packet header may be composed of a packet identification code, a logical number to a physical number mapping table, packet information, and user information. The mapping table is required for the data packet in this embodiment, and a small amount of data, packet information, user information, and the like may be selectively added according to actual use requirements;
逻辑号:数据包存取的编号。当上位机需要读Nand flash中的数据包时,上位机下发的读指令中包括有该数据包对应的逻辑号;Logical number: The number of the packet access. When the upper computer needs to read the data packet in the Nand flash, the read command sent by the upper computer includes the logical number corresponding to the data packet;
物理号:实际存储数据包的物理页的序号,即Nand flash物理页在Nand flash块内的序号;Physical number: the serial number of the physical page of the actual storage packet, that is, the serial number of the Nand flash physical page in the Nand flash block;
最新数据包索引号:指的是存储最新写入的数据包的物理页的物理号;The latest packet index number: refers to the physical number of the physical page that stores the most recently written packet;
不经常写的数据:在写入后很少修改的数据;Data that is not frequently written: data that is rarely modified after writing;
最大物理号:不超过Nand flash块内的物理页总数的设定数;Maximum physical number: no more than the set number of physical pages in the Nand flash block;
FTL: Nand flash转换层;FTL: Nand flash conversion layer;
包标识码:具有一定规则的一串数据,用以获取最新数据包索引号。该包标识码主要用于判别Nand flash页是否已经被使用,进而确定最新数据包索引号。关于上述的逻辑号到物理号的映射法,该逻辑号和物理号都是从0开始顺序编排的自然数序列,建立逻辑号映射到物理号的映射关系,则可以生成对应的映射表,即逻辑号到物理号的映射表。这种映射方法是一种一级映射方法,映射表的更新就是指逻辑号对物理号的映射关系的更新。Packet identification code: A string of data with certain rules to obtain the latest packet index number. The package identification code is mainly used to determine whether the Nand flash page has been used, thereby determining the latest packet index number. Regarding the above-mentioned logical number to physical number mapping method, the logical number and the physical number are natural sequence sequences arranged from 0, and the mapping relationship between the logical number mapping and the physical number is established, and the corresponding mapping table, that is, the logic, can be generated. Number to the physical number mapping table. This mapping method is a first-level mapping method, and the updating of the mapping table refers to the updating of the mapping relationship between the logical number and the physical number.
在本实施例中,Nand flash的写是以页为单位的,每个Nand flash页具有几KBYTE至十几KBYTE的存储空间,在存储少量数据时,完全可以做到一次性存取。针对这个特点,本实施例提供的Nand flash数据处理方法具有以下特点:In this embodiment, Nand The flash is written in units of pages. Each Nand flash page has a storage space of a few KBYTE to a dozen KBYTE. When storing a small amount of data, it can be done once. For this feature, the Nand flash data processing method provided by this embodiment has the following features:
1)建立数据包;1) Establish a data packet;
2)采用两个以上的Nand flash块建立块循环池,在必要时进行数据包的换块操作;2) using two or more Nand flash blocks to create a block loop pool, and if necessary, perform a block swap operation of the data packet;
3)最新写入的数据包记录有最新的映射表;3) The latest written data packet is recorded with the latest mapping table;
4)在存取数据操作前,通过判断是否有包标识码以获取最新数据包索引号,继而根据最新数据包索引号获取最新的映射表,根据逻辑号在获取的最新的映射表中找到其对应的物理号,最后通过物理号可以实现数据包的存取;4) Before accessing the data operation, obtain the latest packet index number by judging whether there is a packet identification code, and then obtain the latest mapping table according to the latest packet index number, and find the latest mapping table according to the logical number in the obtained latest mapping table. Corresponding physical number, and finally access to the data packet through the physical number;
5)在一个Nand flash块用于存储至最大物理号所对应的物理页已被使用后,则使用块循环块池中的下一个Nand flash块;5) After a Nand flash block is used to store the physical page corresponding to the largest physical number has been used, the next Nand flash block in the block cyclic block pool is used;
6)映射表的更新发生在数据包的写、修改和删除等操作。6) The update of the mapping table occurs in the operations of writing, modifying, and deleting data packets.
下面将对本实施例提供的Nand flash的数据处理方法中关于数据包的写、读、修改、删除等操作进行详细描述。The operations of writing, reading, modifying, deleting, etc. of the data packet in the data processing method of the Nand flash provided in this embodiment will be described in detail below.
需要说明的是,为便于描述,在下述内容中,Package_index表示最新数据包索引号,Max_phy_number表示最大物理号, Phy_num表示物理号, LN_ind表示逻辑号,TB_size表示映射表的大小。It should be noted that, for convenience of description, in the following content, Package_index indicates the latest packet index number, Max_phy_number indicates the maximum physical number, Phy_num indicates the physical number, LN_ind indicates the logical number, and TB_size indicates the size of the mapping table.
最新数据包索引号的获取:Get the latest packet index number:
由于在对数据包进行写、读、修改、删除等操作时,大多需要获取当前的Nand flash块中的最新数据包索引号,因此本实施例先介绍该“最新数据包索引号”的获取过程,如图2所示,可以包括以下步骤:Since the most recent packet index number in the current Nand flash block needs to be obtained when the data packet is written, read, modified, deleted, etc., this embodiment first introduces the acquisition process of the "latest packet index number". As shown in Figure 2, the following steps can be included:
201、初始化最新数据包索引号的值,Package_index=Max_phy_number,Phy_num=0;201. Initialize the value of the latest packet index number, Package_index=Max_phy_number, Phy_num=0;
202、判断Phy_num是否小于Max_phy_number,若是,则执行步骤203,若否,则结束;202. Determine whether Phy_num is less than Max_phy_number, if yes, execute step 203, and if no, end;
203、读取Phy_num物理页下的数据包;203. Read a data packet under a physical page of Phy_num.
204、判断读取的数据包中是否具有包标识码,若是,则执行步骤205,若否,则执行步骤206;204, determining whether there is a packet identification code in the read data packet, and if so, executing step 205, if not, executing step 206;
205、Phy_num=Phy_num+1,并返回执行步骤202;205, Phy_num = Phy_num+1, and returns to step 202;
206、若Phy_num大于0,则Package_index=Phy_num-1;若Phy_num不大于0,则Package_index=0;然后结束。206. If Phy_num is greater than 0, then Package_index=Phy_num-1; if Phy_num is not greater than 0, then Package_index=0; then ends.
对于上述步骤201~206,通过对当前Nand flash块中物理号从0开始遍历,直到物理号对应读取到的数据包不具有包标识码,则表明当前物理号的物理页中未写入数据包。从而可知前一个物理号(Phy_num-1)则为最新写入数据包的物理号,也即得到了最新写入数据包的索引号Package_index。特别地,当Phy_num=0时,读取的数据包也不具有包标识码,则表明当前的Nand flash块为一个“新”块,因此确定Package_index=0。For the above steps 201-206, the physical number of the current Nand flash block is traversed from 0 until the data packet corresponding to the physical number does not have the packet identification code, indicating that the data is not written in the physical page of the current physical number. package. Therefore, it can be seen that the previous physical number (Phy_num-1) is the physical number of the latest written data packet, that is, the index number Package_index of the latest written data packet is obtained. In particular, when Phy_num=0, the read packet does not have a packet identification code, indicating that the current Nand flash block is a "new" block, so it is determined that Package_index=0.
数据包的写操作:Packet write operation:
当需要写入数据时,首先需要判断该数据是否属于少量数据,也即是否适合采用本实施例提供的Nand flash的数据处理方法,若是,则进行数据包的写操作。如图3所示,数据包的写入过程可以包括如下步骤:When it is necessary to write data, it is first necessary to determine whether the data belongs to a small amount of data, that is, whether the data processing method of the Nand flash provided by the embodiment is suitable, and if so, the data packet is written. As shown in FIG. 3, the writing process of the data packet may include the following steps:
301、获取需要写入Nand flash的待写入数据;301. Obtain data to be written that needs to be written into the Nand flash.
302、判断所述待写入数据的数据量是否小于预设阈值,若是,则执行步骤303,若否,则采用一般存储方法对待写入数据进行写入操作;302. Determine whether the data amount of the data to be written is less than a preset threshold. If yes, execute step 303. If not, perform a write operation on the data to be written by using a general storage method.
303、根据Package_index读取当前Nand flash块的最新数据包;303. Read the latest data packet of the current Nand flash block according to the Package_index.
304、获取读取的最新数据包中的映射表;304. Obtain a mapping table in the latest data packet read;
305、判断是否Package_index=0且读取的最新数据包中不具有包标识码,若是,则执行步骤306,若否,则执行步骤307;305, determine whether Package_index = 0 and the latest packet read does not have a packet identification code, and if so, step 306 is performed, and if not, step 307 is performed;
306、将所述Package_index确定为新的数据包的物理号,并将分配的逻辑号与所述新的数据包的物理号的映射关系添加至所述映射表的表尾,生成新的映射表,然后执行步骤308;306. Determine the package_index as a physical number of the new data packet, and add a mapping relationship between the assigned logical number and the physical number of the new data packet to the end of the mapping table to generate a new mapping table. Then performing step 308;
307、将Package_index+1确定为新的数据包的物理号,并将分配的逻辑号与所述新的数据包的物理号的映射关系添加至所述映射表的表尾,生成新的映射表;307. Determine Package_index+1 as the physical number of the new data packet, and add a mapping relationship between the assigned logical number and the physical number of the new data packet to the end of the mapping table to generate a new mapping table. ;
308、根据所述待写入数据、所述新的映射表、包信息、用户信息生成所述新的数据包;308. Generate the new data packet according to the to-be-written data, the new mapping table, the packet information, and the user information.
309、将所述新的数据包写入至其物理号对应的物理页内,数据包写入完成。309. Write the new data packet to a physical page corresponding to the physical number, and complete the data packet writing.
对于上述步骤302,上述的“预设阈值”可以是1个Nandflash页的数据,一个Nand flash页的大小可以是4KBYTE、8KBYTE、16KBYTE等。可以理解的是,本实施例提供的Nand flash的数据处理方法更适合用于处理少量数据。因此,当待写入数据不小于预设阈值时,可以认为当前待写入数据并非少量数据,从而可以采用一般存储方法进行写入处理。这里说的一般存储方法是指现有技术中的关于Nand flash的数据存储方法,例如FTL方法。For the above step 302, the foregoing "preset threshold" may be data of one Nandflash page, one Nand The size of the flash page can be 4KBYTE, 8KBYTE, 16KBYTE, and the like. It can be understood that the data processing method of the Nand flash provided by this embodiment is more suitable for processing a small amount of data. Therefore, when the data to be written is not less than the preset threshold, it can be considered that the current data to be written is not a small amount of data, so that the general storage method can be used for the writing process. The general storage method referred to herein refers to a data storage method related to Nand flash in the prior art, such as the FTL method.
对于步骤303,Package_index的获取方法在上述内容中已经进行了详细描述,此处不再赘述。For the step 303, the method for obtaining the package_index has been described in detail in the above content, and details are not described herein again.
对于步骤305,可以理解的是,当Package_index=0且读取的最新数据包中不具有包标识码时,表明当前的Nand flash块为新块,未存在写入的数据包,因此在创建数据包时执行步骤306。For step 305, it can be understood that when Package_index=0 and the latest packet read does not have a packet identification code, it indicates that the current Nand The flash block is a new block, and there is no written packet, so step 306 is performed when the packet is created.
对于步骤306,Package_index对应的物理页不具有包标识码,说明该物理页是空的,因此,该Package_index即为最新可用物理号,直接将该Package_index确定为新的数据包的物理号,建立该新的数据包的物理号与分配的逻辑号之间的映射关系,将该映射关系记录到映射表中。可以理解的是,若无映射表,则可以创建一个新的映射表。For the step 306, the physical page corresponding to the package_index does not have the package identification code, indicating that the physical page is empty. Therefore, the package_index is the latest available physical number, and the package_index is directly determined as the physical number of the new data packet, and the physical number is established. The mapping relationship between the physical number of the new data packet and the assigned logical number, and the mapping relationship is recorded in the mapping table. It can be understood that if there is no mapping table, a new mapping table can be created.
对于步骤306,需要说明的是,所述分配的逻辑号可以由Nand flash为该新的数据包自动分配,也可以通过要求写入所述待写入数据的指令或请求进行确定、分配,本实施例对此不作限定。For step 306, it should be noted that the assigned logical number may be automatically allocated by the Nand flash for the new data packet, or may be determined or allocated by an instruction or request for writing the data to be written. The embodiment does not limit this.
对于步骤307,当当前的Nand flash块并非新块时,由于Package_index对应的物理页已被数据占用,因此为新的数据包分配物理页时,应该选取Package_index+1位置的物理页,即Package_index+1为最新可用物理号。For step 307, when the current Nand flash block is not a new block, since the physical page corresponding to the Package_index is occupied by data, when the physical page is allocated for the new data packet, the physical page of the Package_index+1 position should be selected, that is, Package_index+ 1 is the latest available physical number.
对于步骤308,本实施例中,该包信息和用户信息可以根据待写入数据的来源确定,也可以由获取到的所述最新数据包中的包信息和用户信息更新得来,或者可以采用默认的方式写入这两个信息,对此,本实施例不作限定。For the step 308, in the embodiment, the package information and the user information may be determined according to the source of the data to be written, or may be updated by the obtained package information and user information in the latest data packet, or may be adopted. The two pieces of information are written in the default manner, which is not limited in this embodiment.
对于步骤309,在将新的数据包写入至其物理号对应的物理页之后,为便于下一次的处理操作,还可以设置Package_index=Package_index+1。For step 309, after the new data packet is written to the physical page corresponding to its physical number, in order to facilitate the next processing operation, Package_index=Package_index+1 may also be set.
需要说明的是,在步骤303之前,还可以判断当前Nand flash块的Package_index是否等于Max_phy_number,若是,则表明当前Nand flash块已满,需要执行换块操作,将块循环池中的下一个Nand flash块确定为当前Nand flash块,然后继续执行步骤303;若否,则执行步骤303。It should be noted that, before step 303, it may be determined whether the package_index of the current Nand flash block is equal to Max_phy_number. If yes, it indicates that the current Nand flash block is full, and the block changing operation needs to be performed, and the next Nand flash in the block circulation pool is executed. The block is determined to be the current Nand flash block, and then proceeds to step 303; if not, step 303 is performed.
为便于理解,下面将对换块操作进行详细描述。本实施例中,在Nand flash块的使用过程中,会产生无效的物理页,例如将原先存储有数据包的物理页中的数据包删除,而这些无效的物理页会占用Nand flash块的存储空间,因此,无效的物理页会越来越多,直到Nand flash块已满(即Package_index=Max_phy_number),此时,则进行块循环池的换块操作,将当前Nand flash块的所有数据搬移至下一个Nand flash块。如图4所示,换块操作的过程可以包括以下步骤:For ease of understanding, the block changing operation will be described in detail below. In this embodiment, during the use of the Nand flash block, invalid physical pages are generated, for example, the data packets in the physical page where the data packet was originally stored are deleted, and the invalid physical pages occupy the storage of the Nand flash block. Space, therefore, invalid physical pages will be more and more, until the Nand flash block is full (ie, Package_index = Max_phy_number), at this time, the block cycle pool block operation is performed, and all data of the current Nand flash block is moved to Next Nand flash block. As shown in FIG. 4, the process of the block changing operation may include the following steps:
401、擦除块循环池中的下一个Nand flash块,所述下一个Nand flash块的Phy_num=0;401, erase the next Nand flash block in the block loop pool, Phy_num=0 of the next Nand flash block;
402、根据Package_index读取当前Nand flash块的最新数据包,并获取所述最新数据包的映射表;402. Read the latest data packet of the current Nand flash block according to the Package_index, and obtain a mapping table of the latest data packet.
403、初始化逻辑号LN_ind的值;403. Initialize the value of the logical number LN_ind;
404、判断LN_ind是否小于TB_size,若是,则执行步骤405,若否,则执行步骤408;404, determine whether LN_ind is less than TB_size, and if so, proceed to step 405, and if not, proceed to step 408;
405、根据所述映射表获取LN_ind对应的物理号,并根据获取到的物理号读取数据包;405. Obtain a physical number corresponding to the LN_ind according to the mapping table, and read the data packet according to the obtained physical number.
406、将读取到的数据包的映射表中所述LN_ind对应的物理号更换为所述下一个Nand flash块的Phy_num;406. Replace the physical number corresponding to the LN_ind in the mapping table of the read data packet with the Phy_num of the next Nand flash block.
407、将读取到的所述数据包写入Phy_num对应的物理页内,Phy_num=Phy_num+1,LN_ind=LN_ind+1,然后返回步骤404;407, the read data packet is written into the physical page corresponding to Phy_num, Phy_num = Phy_num+1, LN_ind = LN_ind+1, and then returns to step 404;
408、Package_index=Phy_num,确定所述下一个Nand flash块为当前Nand flash块,换块操作完成,结束。408: Package_index=Phy_num, determining that the next Nand flash block is the current Nand flash block, the block changing operation is completed, and the process ends.
对于上述步骤401~408,先将下一个Nand flash块的数据擦除,从而可以清除该下一个Nand flash块中原有的无效物理页,使得其成为一个新块。然后将根据最新数据包的映射表将当前Nand flash块中的所有有效数据包逐一写入至下一个Nand flash块中,并分别修改各个数据包的映射关系。完成数据的搬迁之后,则可以将下一个Nand flash块确定为当前Nand flash块,完成本次换块操作。For the above steps 401~408, the data of the next Nand flash block is first erased, so that the original invalid physical page in the next Nand flash block can be cleared, so that it becomes a new block. Then, all the valid data packets in the current Nand flash block are written one by one according to the mapping table of the latest data packet to the next Nand flash block, and the mapping relationship of each data packet is modified separately. After the data is relocated, the next Nand flash block can be determined as the current Nand flash block to complete the block swap operation.
数据包的读操作:Packet read operation:
本实施例中,对于已写入Nand flash块中的数据包,可以根据上位机下发的读指令进行读取,如图5所示,具体包括以下步骤:In this embodiment, the data packet that has been written in the Nand flash block can be read according to the read command sent by the host computer. As shown in FIG. 5, the method includes the following steps:
501、获取待读取数据包的读取指令;501. Obtain a read instruction of a data packet to be read;
502、根据所述读取指令确定所述待读取数据包的逻辑号;502. Determine, according to the read instruction, a logical number of the data packet to be read.
503、根据Package_index读取当前Nand flash块中的最新数据包,并获取所述最新数据包中的映射表;503. Read the latest data packet in the current Nand flash block according to the Package_index, and obtain a mapping table in the latest data packet.
504、根据所述逻辑号和所述映射表确定所述待读取数据包的物理号;504. Determine a physical number of the to-be-read data packet according to the logical number and the mapping table.
505、读取确定的所述物理号对应物理页中的数据包。505. The determined physical number corresponds to a data packet in a physical page.
对于上述步骤501,该读取指令可以由与Nand flash连接的上位机发出。For the above step 501, the read command can be issued by the host computer connected to the Nand flash.
对于步骤502,可以理解的是,该读取指令中可以包含有该逻辑号,也可以包含有用于确定该逻辑号的数据包信息,然后根据数据包信息确定该逻辑号,对此不作限定。For the step 502, it can be understood that the logical instruction number may be included in the read instruction, and the data packet information for determining the logical number may be included, and then the logical number is determined according to the data packet information, which is not limited thereto.
对于步骤504,根据映射表中的映射关系,可以确定与该逻辑号对应的该待读取数据包的物理号。可以理解的是,由于本实施例中数据包的写入机制,最新数据包中的映射表包含有当前Nand flash块中所有数据包的逻辑号和物理号的映射关系。For step 504, according to the mapping relationship in the mapping table, the physical number of the data packet to be read corresponding to the logical number may be determined. It can be understood that, due to the writing mechanism of the data packet in this embodiment, the mapping table in the latest data packet includes the mapping relationship between the logical number and the physical number of all the data packets in the current Nand flash block.
对于步骤505,在确定出物理号之后,可以直接根据该物理号读取到所需的数据包,也即该待读取数据包。然后可以将该数据包发送至发出该读取指令的上位机或者其它设备上。For step 505, after determining the physical number, the required data packet, that is, the data packet to be read, can be directly read according to the physical number. The data packet can then be sent to the host computer or other device that issued the read command.
数据包的修改操作:Packet modification operation:
当需要修改数据包中的数据时,上位机或其它设备可以通过下发修改指令使得当前Nand flash块执行修改操作。如图6所示,数据包的修改过程可以包括以下步骤:When the data in the data packet needs to be modified, the host computer or other device can perform the modification operation by issuing the modification instruction to the current Nand flash block. As shown in FIG. 6, the modification process of the data packet may include the following steps:
601、获取待修改数据包的修改指令以及待修改的数据;601. Obtain a modification instruction of the data packet to be modified and data to be modified;
602、根据所述修改指令确定所述待修改数据包的逻辑号;602. Determine a logical number of the to-be-modified data packet according to the modification instruction.
603、根据Package_index读取当前Nand flash块中的最新数据包,并获取所述最新数据包中的映射表;603. Read the latest data packet in the current Nand flash block according to the Package_index, and obtain a mapping table in the latest data packet.
604、根据所述逻辑号和所述映射表确定所述待修改数据包的物理号;604. Determine a physical number of the to-be-modified data packet according to the logical number and the mapping table.
605、读取确定的所述物理号对应物理页中的数据包;605. The determined physical number corresponds to a data packet in a physical page.
606、将Package_index+1更新为所述映射表中所述逻辑号对应的物理号,得到新的映射表;606. Update the package_index+1 to a physical number corresponding to the logical number in the mapping table, to obtain a new mapping table.
607、采用所述待修改的数据修改读取的所述数据包中的数据;607. Modify data in the read data packet by using the data to be modified.
608、根据修改后的数据、所述新的映射表、包信息以及用户信息生成新的数据包;608. Generate a new data packet according to the modified data, the new mapping table, the package information, and the user information.
609、将所述新的数据包写入至其物理号对应的物理页内,数据包修改完成。609. Write the new data packet to a physical page corresponding to the physical number, and complete the data packet modification.
对于步骤601,该修改指令可以由与Nand flash连接的上位机发出。并且,在获取修改指令的同时,可以获取到数据包待修改的数据,也即需要更新的数据。For step 601, the modification instruction can be issued by the host computer connected to the Nand flash. Moreover, while obtaining the modification instruction, the data to be modified by the data packet, that is, the data to be updated, may be acquired.
对于步骤602,可以理解的是,该修改指令中可以包含有该逻辑号,也可以包含有用于确定该逻辑号的数据包信息,然后根据数据包信息确定该逻辑号,对此不作限定。For the step 602, it can be understood that the modified instruction may include the logical number, or may include the data packet information for determining the logical number, and then determine the logical number according to the data packet information, which is not limited thereto.
对于步骤604,根据映射表中的映射关系,可以确定与该逻辑号对应的该待修改数据包的物理号。可以理解的是,由于本实施例中数据包的写入机制,最新数据包中的映射表包含有当前Nand flash块中所有数据包的逻辑号和物理号的映射关系。For step 604, according to the mapping relationship in the mapping table, the physical number of the to-be-modified data packet corresponding to the logical number may be determined. It can be understood that, due to the writing mechanism of the data packet in this embodiment, the mapping table in the latest data packet includes the mapping relationship between the logical number and the physical number of all the data packets in the current Nand flash block.
对于步骤605,在确定出物理号之后,可以直接根据该物理号读取到所需的数据包,也即该待修改数据包。For step 605, after determining the physical number, the required data packet, that is, the data packet to be modified, can be directly read according to the physical number.
对于步骤606,在本实施例中,在修改数据包时,并非在原物理页上直接进行数据的修改,而是将更新后的数据以写入的方式写入至空的物理页中。因此,将Package_index+1作为该数据包的物理号,相当于为修改后的数据包分配最新的物理页。For step 606, in the present embodiment, when the data packet is modified, the data is not directly modified on the original physical page, but the updated data is written into the empty physical page in a written manner. Therefore, using Package_index+1 as the physical number of the packet is equivalent to allocating the latest physical page to the modified packet.
对于步骤607,在读取待修改的数据包之后,使用待修改的数据修改该数据包中的数据,实现数据的更新。For step 607, after reading the data packet to be modified, the data in the data packet is modified using the data to be modified to implement data update.
对于步骤608,根据修改后的数据和新的映射表,以及包信息、用户信息生成新的数据包。其中,该包信息和用户信息可以根据修改指令来确定,也可以由读取到的待修改数据包中的包信息和用户信息更新得来,或者可以采用默认的方式写入这两个信息,对此,本实施例不作限定。For step 608, a new data packet is generated based on the modified data and the new mapping table, as well as the package information and the user information. The package information and the user information may be determined according to the modification instruction, or may be updated by the package information and the user information in the read data packet to be modified, or the two information may be written in a default manner. In this regard, the embodiment is not limited.
对于步骤609,在生成新的数据包,也即修改后的数据包之后,可以将所述新的数据包写入至其物理号对应的物理页内,也即Package_index+1对应的物理页内,数据包修改完成。For step 609, after generating a new data packet, that is, after the modified data packet, the new data packet may be written into a physical page corresponding to its physical number, that is, a physical page corresponding to Package_index+1. The packet modification is complete.
需要说明的是,在步骤603之前,还可以判断当前Nand flash块的Package_index是否等于Max_phy_number,若是,则表明当前Nand flash块已满,需要执行换块操作,将块循环池中的下一个Nand flash块确定为当前Nand flash块,然后再执行步骤603;若否,则执行步骤603。It should be noted that, before step 603, it may be determined whether the package_index of the current Nand flash block is equal to Max_phy_number. If yes, it indicates that the current Nand flash block is full, and the block changing operation needs to be performed, and the next Nand flash in the block circulation pool is executed. The block is determined to be the current Nand flash block, and then step 603 is performed; if not, step 603 is performed.
由上述步骤601~609可知,对数据包进行修改之后,由于修改前的数据包占用的物理页被“放弃”,修改后的数据包重新写入最新的物理页中,从而会导致当前的Nand flash块增加一个无效页(即被“放弃”的物理页)。It can be seen from the above steps 601-609 that after the data packet is modified, since the physical page occupied by the data packet before the modification is "abandoned", the modified data packet is rewritten into the latest physical page, thereby causing the current Nand. The flash block adds an invalid page (that is, a physical page that is "abandoned").
数据包的删除操作:Packet deletion:
当需要删除数据包时,上位机或其它设备可以通过下发删除指令使得当前Nand flash块执行删除操作。如图7所示,数据包的删除过程可以包括以下步骤:When the data packet needs to be deleted, the host computer or other device can cause the current Nand flash block to perform the delete operation by issuing a delete instruction. As shown in FIG. 7, the process of deleting a data packet may include the following steps:
701、获取待删除数据包的删除指令;701. Obtain a deletion instruction of the data packet to be deleted.
702、根据所述删除指令确定所述待删除数据包的逻辑号;702. Determine a logical number of the to-be-deleted data packet according to the deleting instruction.
703、根据Package_index读取当前Nand flash块中的最新数据包,并获取所述最新数据包中的映射表;703. Read the latest data packet in the current Nand flash block according to the Package_index, and obtain a mapping table in the latest data packet.
704、从所述映射表中删除所述逻辑号与对应的物理号之间的映射关系,得到新的映射表;704. Delete a mapping relationship between the logical number and a corresponding physical number from the mapping table, to obtain a new mapping table.
705、根据所述新的映射表和包信息生成新的数据包;705. Generate a new data packet according to the new mapping table and packet information.
706、将所述新的数据包写入至Package_index+1对应的物理页内,数据包删除完成。706. Write the new data packet to a physical page corresponding to Package_index+1, and complete the data packet deletion.
对于步骤701,该删除指令可以由与Nand flash连接的上位机发出。For step 701, the delete command can be issued by the host computer connected to the Nand flash.
对于步骤702,可以理解的是,该删除指令中可以包含有该逻辑号,也可以包含有用于确定该逻辑号的数据包信息,然后根据数据包信息确定该逻辑号,对此不作限定。For the step 702, it can be understood that the logical instruction number may be included in the deletion instruction, and the data packet information for determining the logical number may be included, and then the logical number is determined according to the data packet information, which is not limited thereto.
对于步骤704,可以理解的是,在删除Nand flash块中的数据包时,只需要删除该数据包的逻辑号与物理号之间的映射关系即可,因为当映射关系删除后,对于Nand flash以外的设备来说,已删除的数据包是不可知的。而由于当前Nand flash块中所有数据包的确定均通过最新数据包中的映射表来查询,因此需要删除了该映射关系后,生成新的映射表并执行步骤705,生成一个新的数据包。For step 704, it can be understood that when deleting a data packet in the Nand flash block, only the mapping relationship between the logical number and the physical number of the data packet needs to be deleted, because when the mapping relationship is deleted, for the Nand flash For devices other than the ones, the deleted packets are unknown. And because of the current Nand The determination of all the data packets in the flash block is queried through the mapping table in the latest data packet. Therefore, after the mapping relationship needs to be deleted, a new mapping table is generated and step 705 is executed to generate a new data packet.
对于步骤705,可知,生成的新的数据包里面不具有可用的有效数据,其作用在于记录新的映射表,并让该新的映射表在需要时可被读取到。For step 705, it can be seen that the generated new data packet does not have valid data available therein, and its function is to record a new mapping table and allow the new mapping table to be read when needed.
对于步骤706,在生成新的数据包之后,将该新的数据包写入到最新的物理页中,也即Package_index+1对应的物理页内,数据包删除操作完成。For step 706, after generating a new data packet, the new data packet is written into the latest physical page, that is, the physical page corresponding to Package_index+1, and the data packet deletion operation is completed.
需要说明的是,在步骤703之前,还可以判断当前Nand flash块的Package_index是否等于Max_phy_number,若是,则表明当前Nand flash块已满,需要执行换块操作,将块循环池中的下一个Nand flash块确定为当前Nand flash块,然后再执行步骤703;若否,则执行步骤703。It should be noted that, before step 703, it may be determined whether the package_index of the current Nand flash block is equal to Max_phy_number, and if so, it indicates that the current Nand flash block is full, and the block changing operation needs to be performed, and the next Nand flash in the block circulation pool is executed. The block is determined to be the current Nand flash block, and then step 703 is performed; if not, step 703 is performed.
由上述步骤701~706可知,对数据包进行删除之后,由于删除前的数据包占用的物理页被“放弃”,删除后生成的记录新的映射表的数据包写入最新的物理页中,从而会导致当前的Nand flash块增加一个无效页(即被“放弃”的物理页)。It can be seen from the above steps 701 to 706 that after the data packet is deleted, the physical page occupied by the data packet before the deletion is “abandoned”, and the data packet of the new mapping table generated after the deletion is written into the latest physical page. This will cause the current Nand flash block to add an invalid page (ie, a physical page that is "abandoned").
可见,本实施例中,随着对数据包的修改操作和删除操作的增多,当前Nand flash块中的无效页会越来越多,最后导致Nand flash块已满,从而需要执行换块操作。而由于换块操作时将下一个Nand flash块进行擦除处理,因此,即便将当前Nand flash块的所有有效数据包搬移至下一个Nand flash块中,该换块操作也是有意义的,相当于把下一个Nand flash块中的无效页清理掉。It can be seen that, in this embodiment, as the modification operation and the deletion operation of the data packet increase, the number of invalid pages in the current Nand flash block will increase more and more, and finally the Nand flash block is full, and thus the block changing operation needs to be performed. Since the next Nand flash block is erased during the block changing operation, even if all the valid data packets of the current Nand flash block are moved to the next Nand flash block, the swapping operation is meaningful, which is equivalent to Clean up the invalid pages in the next Nand flash block.
需要说明的是,在本实施例中,可以在Nand flash上执行上述的写、读、修改、删除、换块等操作,可以只单独执行其中的某一个或多个操作,例如对某个Nand flash执行写操作,再执行修改操作、删除操作。应当可以理解的是,在Nand flash上可以执行上述写、读、修改、删除、换块等操作的任意组合,以及这些操作之间的执行次序均没有限定。It should be noted that, in this embodiment, the above operations of writing, reading, modifying, deleting, changing blocks, and the like may be performed on the Nand flash, and only one or more operations may be performed separately, for example, for a certain Nand. The flash performs a write operation, and then performs a modify operation and a delete operation. It should be understandable that in Nand Any combination of the above operations of writing, reading, modifying, deleting, changing blocks, and the like can be performed on the flash, and the order of execution between these operations is not limited.
实施例二:Embodiment 2:
本实施例还提供一种Nand flash的数据处理装置,其应用于在所述Nand flash中指定的Nand flash块,主要进行Nand flash块的数据写入处理。如图8所示,所述Nand flash的数据处理装置包括:This embodiment also provides a Nand A flash data processing device is applied to the Nand flash block specified in the Nand flash, and mainly performs data writing processing of the Nand flash block. As shown in FIG. 8, the data processing apparatus of the Nand flash includes:
写入数据获取模块801,用于获取待写入数据;Writing data acquisition module 801, configured to acquire data to be written;
第一最新数据包读取模块802,用于若所述待写入数据的数据量小于预设阈值,则根据最新数据包索引号读取当前Nand flash块的最新数据包,所述最新数据包索引号为所述当前Nand flash块中存储最新写入的数据包的物理页对应的物理号;The first latest packet reading module 802 is configured to: if the data volume of the data to be written is less than a preset threshold, read the current Nand according to the latest packet index number. The latest data packet of the flash block, wherein the latest data packet index number is a physical number corresponding to the physical page of the current Nand flash block storing the newly written data packet;
第一映射表获取模块803,用于获取所述最新数据包中的映射表,所述映射表记录有所述当前Nand flash块中存储的各个数据包的逻辑号与物理号之间的映射关系;The first mapping table obtaining module 803 is configured to obtain a mapping table in the latest data packet, where the mapping table records a mapping relationship between a logical number and a physical number of each data packet stored in the current Nand flash block. ;
映射关系建立模块804,用于建立分配给所述待写入数据的逻辑号与最新可用物理号之间的映射关系,所述最新可用物理号为所述当前Nand flash块中最新的可用物理页对应的物理号;The mapping relationship establishing module 804 is configured to establish a mapping relationship between the logical number assigned to the data to be written and the latest available physical number, where the latest available physical number is the latest available physical page in the current Nand flash block. Corresponding physical number;
第一新映射表生成模块805,用于将建立的所述映射关系添加至所述映射表中,生成新的映射表;a first new mapping table generating module 805, configured to add the established mapping relationship to the mapping table, to generate a new mapping table;
第一新数据包生成模块806,用于根据所述新的映射表和所述待写入数据生成新的数据包;a first new data packet generating module 806, configured to generate a new data packet according to the new mapping table and the to-be-written data;
第一写入模块807,用于将所述新的数据包写入所述最新可用物理号对应的物理页内。The first writing module 807 is configured to write the new data packet into a physical page corresponding to the latest available physical number.
实施例三:Embodiment 3:
本实施例还提供一种Nand flash的数据处理装置,其应用于在所述Nand flash中指定的Nand flash块,所述Nand flash块中存储有预设格式的数据包。该Nand flash的数据处理装置主要进行Nand flash块的数据读取处理。如图9所示,所述Nand flash的数据处理装置包括:This embodiment also provides a Nand A flash data processing device is applied to a Nand flash block specified in the Nand flash, and the Nand flash block stores a data packet in a preset format. The data processing device of the Nand flash mainly performs data reading processing of the Nand flash block. As shown in FIG. 9, the data processing apparatus of the Nand flash includes:
读取指令获取模块901,用于获取待读取数据包的读取指令;The read instruction obtaining module 901 is configured to acquire a read instruction of the data packet to be read;
第一包号确定模块902,用于根据所述读取指令确定所述待读取数据包的逻辑号;a first packet number determining module 902, configured to determine a logical number of the to-be-read data packet according to the read instruction;
第二最新数据包读取模块903,用于根据最新数据包索引号读取当前Nand flash块的最新数据包,所述最新数据包索引号为所述当前Nand flash块中存储最新写入的数据包的物理页对应的物理号;The second latest packet reading module 903 is configured to read the latest data packet of the current Nand flash block according to the latest data packet index number, where the latest data packet index number is the latest data written in the current Nand flash block. The physical number corresponding to the physical page of the package;
第二映射表获取模块904,用于获取所述最新数据包中的映射表,所述映射表记录有所述当前Nand flash块中存储的各个数据包的逻辑号与物理号之间的映射关系;The second mapping table obtaining module 904 is configured to obtain a mapping table in the latest data packet, where the mapping table records a mapping relationship between a logical number and a physical number of each data packet stored in the current Nand flash block. ;
第一物理号确定模块905,用于根据所述逻辑号和所述映射表确定所述待读取数据包的物理号;The first physical number determining module 905 is configured to determine, according to the logical number and the mapping table, a physical number of the data packet to be read;
第一数据包读取单元906,用于读取确定的所述物理号对应物理页中的数据包。The first packet reading unit 906 is configured to read the determined data packet in the physical page corresponding to the physical number.
实施例四:Embodiment 4:
本实施例还提供一种Nand flash的数据处理装置,其应用于在所述Nand flash中指定的Nand flash块,所述Nand flash块中存储有预设格式的数据包。该Nand flash的数据处理装置主要进行Nand flash块的数据修改处理。如图10所示,所述Nand flash的数据处理装置包括:This embodiment also provides a Nand A flash data processing device is applied to a Nand flash block specified in the Nand flash, and the Nand flash block stores a data packet in a preset format. The data processing device of the Nand flash mainly performs data modification processing of the Nand flash block. As shown in FIG. 10, the data processing apparatus of the Nand flash includes:
修改指令获取模块1001,用于获取待修改数据包的修改指令以及待修改的数据;The instruction fetching module 1001 is configured to obtain a modification instruction of the data packet to be modified and data to be modified;
第二包号确定模块1002,用于根据所述修改指令确定所述待修改数据包的逻辑号;a second packet number determining module 1002, configured to determine a logical number of the to-be-modified data packet according to the modification instruction;
第三最新数据包读取模块1003,用于根据最新数据包索引号读取当前Nand flash块的最新数据包,所述最新数据包索引号为所述当前Nand flash块中存储最新写入的数据包的物理页对应的物理号;The third latest packet reading module 1003 is configured to read the latest data packet of the current Nand flash block according to the latest data packet index number, where the latest data packet index number is the latest data written in the current Nand flash block. The physical number corresponding to the physical page of the package;
第三映射表获取模块1004,用于获取所述最新数据包中的映射表,所述映射表记录有所述当前Nand flash块中存储的各个数据包的逻辑号与物理号之间的映射关系;The third mapping table obtaining module 1004 is configured to obtain a mapping table in the latest data packet, where the mapping table records a mapping relationship between a logical number and a physical number of each data packet stored in the current Nand flash block. ;
第二物理号确定模块1005,用于根据所述逻辑号和所述映射表确定所述待修改数据包的物理号;a second physical number determining module 1005, configured to determine, according to the logical number and the mapping table, a physical number of the to-be-modified data packet;
第二数据包读取单元1006,用于读取确定的所述物理号对应物理页中的数据包;The second packet reading unit 1006 is configured to read the determined data packet in the physical page corresponding to the physical number;
第二新映射表生成模块1007,用于将所述映射表中所述逻辑号对应的物理号更新为最新可用物理号,得到新的映射表,所述最新可用物理号为所述当前Nand flash块中最新的可用物理页对应的物理号;The second new mapping table generating module 1007 is configured to update the physical number corresponding to the logical number in the mapping table to the latest available physical number, to obtain a new mapping table, where the latest available physical number is the current Nand flash The physical number corresponding to the latest available physical page in the block;
数据修改模块1008,用于采用所述待修改的数据修改读取的所述数据包中的数据;a data modification module 1008, configured to modify data in the read data packet by using the data to be modified;
第二新数据包生成模块1009,用于根据修改后的数据和所述新的映射表生成新的数据包;a second new data packet generating module 1009, configured to generate a new data packet according to the modified data and the new mapping table;
第二写入模块1010,用于将所述新的数据包写入所述最新可用物理号对应的物理页内。The second writing module 1010 is configured to write the new data packet into a physical page corresponding to the latest available physical number.
实施例五:Embodiment 5:
本实施例还提供一种Nand flash的数据处理装置,其应用于在所述Nand flash中指定的Nand flash块,所述Nand flash块中存储有预设格式的数据包。该Nand flash的数据处理装置主要进行Nand flash块的数据读取处理。如图11所示,所述Nand flash的数据处理装置包括:This embodiment also provides a Nand A flash data processing device is applied to a Nand flash block specified in the Nand flash, and the Nand flash block stores a data packet in a preset format. The data processing device of the Nand flash mainly performs data reading processing of the Nand flash block. As shown in FIG. 11, the data processing apparatus of the Nand flash includes:
删除指令获取模块111,用于获取待删除数据包的删除指令;The deletion instruction obtaining module 111 is configured to acquire a deletion instruction of the data packet to be deleted;
第三包号确定模块112,用于根据所述删除指令确定所述待删除数据包的逻辑号;a third packet number determining module 112, configured to determine a logical number of the to-be-deleted data packet according to the deleting instruction;
第四最新数据包读取模块113,用于根据最新数据包索引号读取当前Nand flash块的最新数据包,所述最新数据包索引号为所述当前Nand flash块中存储最新写入的数据包的物理页对应的物理号;The fourth latest packet reading module 113 is configured to read the latest data packet of the current Nand flash block according to the latest data packet index number, where the latest data packet index number is the latest data written in the current Nand flash block. The physical number corresponding to the physical page of the package;
第四映射表获取模块114,用于获取所述最新数据包中的映射表,所述映射表记录有所述当前Nand flash块中存储的各个数据包的逻辑号与物理号之间的映射关系;The fourth mapping table obtaining module 114 is configured to obtain a mapping table in the latest data packet, where the mapping table records a mapping relationship between a logical number and a physical number of each data packet stored in the current Nand flash block. ;
第三新映射表生成模块115,用于从所述映射表中删除所述逻辑号与对应的物理号之间的映射关系,得到新的映射表;a third new mapping table generating module 115, configured to delete a mapping relationship between the logical number and a corresponding physical number from the mapping table, to obtain a new mapping table;
第三新数据包生成模块116,用于根据所述新的映射表生成新的数据包;a third new data packet generating module 116, configured to generate a new data packet according to the new mapping table;
第三写入模块117,用于将所述新的数据包写入最新可用物理号对应的物理页内,所述最新可用物理号为所述当前Nand flash块中最新的可用物理页对应的物理号。a third writing module 117, configured to write the new data packet into a physical page corresponding to a latest available physical number, where the latest available physical number is a physical corresponding to the latest available physical page in the current Nand flash block. number.
实施例六:Example 6:
本实施例还提供一种在上述图8、图10或图11对应实施例中描述的任意一种Nand flash的数据处理装置的基础上进一步改进的Nand flash块处理装置。在实施例六描述的Nand flash块处理装置中,所述Nand flash中设有由两个以上指定的Nand flash块组成的块循环池。如图12所示,该Nand flash块处理装置还包括:The embodiment further provides a Nand flash block processing apparatus which is further improved on the basis of the data processing apparatus of any of the Nand flash described in the foregoing embodiments of FIG. 8, FIG. 10 or FIG. In the Nand flash block processing apparatus described in Embodiment 6, the Nand flash is provided with a block circulation pool composed of two or more specified Nand flash blocks. As shown in FIG. 12, the Nand flash block processing apparatus further includes:
满载判断模块121,用于判断所述当前Nand flash块是否已满;The full load judging module 121 is configured to determine whether the current Nand flash block is full;
第一触发模块122,用于若所述满载判断模块121的判断结果为否,则触发上述的第一最新数据包读取模块802、第三最新数据包读取模块1003或第四最新数据包读取模块113;The first triggering module 122 is configured to trigger the first latest packet reading module 802, the third latest packet reading module 1003, or the fourth latest packet if the determination result of the full load determining module 121 is negative. Reading module 113;
第二触发模块123,用于若所述满载判断模块121的判断结果为是,则触发换块模块124,然后触发上述的第一最新数据包读取模块802、第三最新数据包读取模块1003或第四最新数据包读取模块113;The second triggering module 123 is configured to trigger the block changing module 124 if the determination result of the full load determining module 121 is YES, and then trigger the first latest packet reading module 802 and the third latest packet reading module. 1003 or fourth latest packet reading module 113;
所述换块模块124具体可以包括以下单元:The block changing module 124 may specifically include the following units:
块擦除单元1241,用于擦除所述块循环池中的下一个Nand flash块;a block erasing unit 1241, configured to erase a next Nand flash block in the block cycle pool;
最新数据包读取单元1242,用于根据最新数据包索引号读取所述当前Nand flash块的最新数据包;The latest packet reading unit 1242 is configured to read the latest data packet of the current Nand flash block according to the latest packet index number;
映射表获取单元1243,用于获取所述最新数据包中的映射表;a mapping table obtaining unit 1243, configured to acquire a mapping table in the latest data packet;
初始化单元1244,用于初始化第一逻辑号的值;An initializing unit 1244, configured to initialize a value of the first logical number;
数据包搬移单元1245,用于通过调整所述第一逻辑号的值依据所述映射表依次读取所述当前Nand flash块中的各个数据包,并将读取到的所述各个数据包依次写入所述下一个Nand flash块,直到所述当前Nand flash块中的各个数据包均写入至所述下一个Nand flash块;The packet shifting unit 1245 is configured to sequentially read each data packet in the current Nand flash block according to the mapping table by adjusting the value of the first logical number, and sequentially read the read each data packet. Write to the next Nand a flash block until each data packet in the current Nand flash block is written to the next Nand flash block;
当前块确定单元1246,用于将所述下一个Nand flash块确定为当前Nand flash块。The current block determining unit 1246 is configured to determine the next Nand flash block as the current Nand flash block.
实施例七:Example 7:
本实施例还提供一种Nand flash,其包括图8至图11对应实施例中描述的任意一种Nand flash的数据处理装置,和/或,包括图12对应实施例中描述的任意一种Nand flash块处理装置。特别地,该Nand flash也可以包括上述图8至图12对应实施例中描述的所有形式的Nand flash的数据处理装置和Nand flash块处理装置。This embodiment also provides a Nand A flash, which includes the data processing apparatus of any of the Nand flashes described in the embodiments of FIG. 8 to FIG. 11, and/or includes any of the Nand flash block processing apparatuses described in the corresponding embodiment of FIG. In particular, the Nand flash may also include the data processing apparatus and the Nand flash block processing apparatus of all forms of Nand flash described in the above embodiments of FIGS. 8 to 12.
实施例八:Example 8:
图13是本申请实施例提供的电子设备13的硬件结构示意图,如图13所示,该电子设备13包括:FIG. 13 is a schematic diagram of a hardware structure of an electronic device 13 according to an embodiment of the present disclosure. As shown in FIG. 13, the electronic device 13 includes:
一个或多个处理器131以及存储器132,图13中以一个处理器131为例。One or more processors 131 and memory 132, one processor 131 is exemplified in FIG.
处理器131和存储器132可以通过总线或者其他方式连接,图13中以通过总线连接为例。The processor 131 and the memory 132 may be connected by a bus or other means, as exemplified by a bus connection in FIG.
存储器132作为一种非易失性计算机可读存储介质,可用于存储非易失性软件程序、非易失性计算机可执行程序以及模块,如本申请实施例中的Nand flash的数据处理方法对应的程序指令/模块(例如,附图8所示的模块)。处理器131通过运行存储在存储器132中的非易失性软件程序、指令以及模块,从而执行电子设备的各种功能应用以及数据处理,即实现上述方法实施例Nand flash的数据处理方法。The memory 132 is a non-volatile computer readable storage medium, and can be used for storing a non-volatile software program, a non-volatile computer-executable program, and a module, as in the Nand flash data processing method in the embodiment of the present application. Program instructions/modules (eg, the modules shown in Figure 8). The processor 131 executes various functional applications and data processing of the electronic device by executing non-volatile software programs, instructions, and modules stored in the memory 132, that is, the data processing method of the Nand flash of the above-described method embodiment.
存储器132可以包括存储程序区和存储数据区,其中,存储程序区可存储操作***、至少一个功能所需要的应用程序;存储数据区可存储根据Nand flash的数据处理装置的使用所创建的数据等。此外,存储器132可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他非易失性固态存储器件。在一些实施例中,存储器132可选包括相对于处理器131远程设置的存储器,这些远程存储器可以通过网络连接至Nand flash的数据处理装置。上述网络的实例包括但不限于互联网、企业内部网、局域网、移动通信网及其组合。The memory 132 may include a storage program area and an storage data area, wherein the storage program area may store an operating system, an application required for at least one function; the storage data area may store data created according to the use of the data processing device of the Nand flash, and the like. . Moreover, memory 132 can include high speed random access memory, and can also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some embodiments, the memory 132 can optionally include a memory remotely located relative to the processor 131 that can be connected to the data processing device of the Nand flash via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
所述一个或者多个模块存储在所述存储器132中,当被所述一个或者多个处理器131执行时,执行上述任意方法实施例中的Nand flash的数据处理方法,例如,执行以上描述的图2中的方法步骤、图3中的方法步骤、图4中的方法步骤、图5中的方法步骤、图6中的方法步骤、图7中的方法步骤,以及图8中的模块、图9中的模块、图10中的模块、图11中的模块、图12中的模块的功能。The one or more modules are stored in the memory 132, and when executed by the one or more processors 131, perform a data processing method of the Nand flash in any of the above method embodiments, for example, performing the above description. The method steps in FIG. 2, the method steps in FIG. 3, the method steps in FIG. 4, the method steps in FIG. 5, the method steps in FIG. 6, the method steps in FIG. 7, and the modules and figures in FIG. The functions of the modules in 9, the modules in Figure 10, the modules in Figure 11, and the modules in Figure 12.
上述产品可执行本申请实施例所提供的方法,具备执行方法相应的功能模块和有益效果。未在本实施例中详尽描述的技术细节,可参见本申请实施例所提供的方法。The above products can perform the methods provided by the embodiments of the present application, and have the corresponding functional modules and beneficial effects of the execution method. For technical details that are not described in detail in this embodiment, reference may be made to the method provided by the embodiments of the present application.
本申请实施例的电子设备以多种形式存在,例如闪存设备等。The electronic device of the embodiment of the present application exists in various forms, such as a flash memory device or the like.
本申请实施例提供了一种非易失性计算机可读存储介质,所述计算机可读存储介质存储有计算机可执行指令,该计算机可执行指令被一个或多个处理器执行,例如,执行以上描述的图2中的方法步骤、图3中的方法步骤、图4中的方法步骤、图5中的方法步骤、图6中的方法步骤、图7中的方法步骤,以及图8中的模块、图9中的模块、图10中的模块、图11中的模块、图12中的模块的功能。Embodiments of the present application provide a non-transitory computer readable storage medium storing computer-executable instructions that are executed by one or more processors, for example, to perform the above The method steps in FIG. 2, the method steps in FIG. 3, the method steps in FIG. 4, the method steps in FIG. 5, the method steps in FIG. 6, the method steps in FIG. 7, and the modules in FIG. The functions of the module in FIG. 9, the module in FIG. 10, the module in FIG. 11, and the module in FIG.
本申请实施例提供了一种计算机程序产品,所述计算机程序产品包括存储在非易失性计算机可读存储介质上的计算机程序,所述计算机程序包括程序指令,当所述程序指令被计算机执行时,使所述计算机执行上述任意方法实施例中的Nand flash的数据处理方法,例如,执行以上描述的图2中的方法步骤、图3中的方法步骤、图4中的方法步骤、图5中的方法步骤、图6中的方法步骤、图7中的方法步骤,以及图8中的模块、图9中的模块、图10中的模块、图11中的模块、图12中的模块的功能。The embodiment of the present application provides a computer program product, the computer program product comprising a computer program stored on a non-transitory computer readable storage medium, the computer program comprising program instructions, when the program instructions are executed by a computer When the computer is executed, the data processing method of the Nand flash in any of the above method embodiments is performed, for example, the method steps in FIG. 2, the method steps in FIG. 3, the method steps in FIG. 4, and FIG. 5 are performed. Method steps in the method, method steps in FIG. 6, method steps in FIG. 7, and modules in FIG. 8, modules in FIG. 9, modules in FIG. 10, modules in FIG. 11, modules in FIG. Features.
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的***,装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。A person skilled in the art can clearly understand that for the convenience and brevity of the description, the specific working process of the system, the device and the unit described above can refer to the corresponding process in the foregoing method embodiment, and details are not described herein again.
在本申请所提供的几个实施例中,应该理解到,所揭露的***,装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个***,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided by the present application, it should be understood that the disclosed system, apparatus, and method may be implemented in other manners. For example, the device embodiments described above are merely illustrative. For example, the division of the unit is only a logical function division. In actual implementation, there may be another division manner, for example, multiple units or components may be combined or Can be integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, and may be in an electrical, mechanical or other form.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。The integrated unit, if implemented in the form of a software functional unit and sold or used as a standalone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application, in essence or the contribution to the prior art, or all or part of the technical solution may be embodied in the form of a software product stored in a storage medium. A number of instructions are included to cause a computer device (which may be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present application. The foregoing storage medium includes: a U disk, a mobile hard disk, a read only memory (ROM, Read-Only) Memory), random access memory (RAM, Random) A variety of media that can store program code, such as Access Memory, disk, or optical disk.
以上所述,以上实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围。The above embodiments are only used to explain the technical solutions of the present application, and are not limited thereto; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can still The technical solutions described in the embodiments are modified, or the equivalents of the technical features are replaced by the equivalents. The modifications and substitutions of the embodiments do not depart from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims (13)

  1. 一种Nand flash的数据处理方法,其特征在于,应用于在所述Nand flash中指定的Nand flash块; A Nand flash data processing method, which is applied to a Nand flash block specified in the Nand flash;
    所述Nand flash的数据处理方法包括:The Nand Flash data processing methods include:
    获取待写入数据;Get the data to be written;
    若所述待写入数据的数据量小于预设阈值,则根据最新数据包索引号读取当前Nand flash块的最新数据包,所述最新数据包索引号为所述当前Nand flash块中存储最新写入的数据包的物理页对应的物理号;If the data volume of the data to be written is less than a preset threshold, reading the latest data packet of the current Nand flash block according to the latest data packet index number, where the latest data packet index number is the latest in the current Nand flash block. The physical number corresponding to the physical page of the written packet;
    获取所述最新数据包中的映射表,所述映射表记录有所述当前Nand flash块中存储的各个数据包的逻辑号与物理号之间的映射关系;Obtaining, in the latest data packet, a mapping table, where the mapping table records a mapping relationship between a logical number and a physical number of each data packet stored in the current Nand flash block;
    建立分配给所述待写入数据的逻辑号与最新可用物理号之间的映射关系,所述最新可用物理号为所述当前Nand flash块中最新的可用物理页对应的物理号;Establishing a mapping relationship between the logical number assigned to the data to be written and the latest available physical number, where the latest available physical number is a physical number corresponding to the latest available physical page in the current Nand flash block;
    将建立的所述映射关系添加至所述映射表中,生成新的映射表;Adding the established mapping relationship to the mapping table to generate a new mapping table;
    根据所述新的映射表和所述待写入数据生成新的数据包;Generating a new data packet according to the new mapping table and the to-be-written data;
    将所述新的数据包写入所述最新可用物理号对应的物理页内。The new data packet is written into a physical page corresponding to the latest available physical number.
  2. 一种Nand flash的数据处理方法,其特征在于,应用于在所述Nand flash中指定的Nand flash块,所述Nand flash块中存储有预设格式的数据包; A Nand flash data processing method, which is applied to a Nand flash block specified in the Nand flash, where the Nand flash block stores a data packet in a preset format;
    所述Nand flash的数据处理方法包括:The Nand Flash data processing methods include:
    获取待读取数据包的读取指令;Obtaining a read instruction of the data packet to be read;
    根据所述读取指令确定所述待读取数据包的逻辑号;Determining, according to the read instruction, a logical number of the data packet to be read;
    根据最新数据包索引号读取当前Nand flash块的最新数据包,所述最新数据包索引号为所述当前Nand flash块中存储最新写入的数据包的物理页对应的物理号;Reading the latest data packet of the current Nand flash block according to the latest data packet index number, where the latest data packet index number is a physical number corresponding to the physical page of the current Nand flash block storing the newly written data packet;
    获取所述最新数据包中的映射表,所述映射表记录有所述当前Nand flash块中存储的各个数据包的逻辑号与物理号之间的映射关系;Obtaining, in the latest data packet, a mapping table, where the mapping table records a mapping relationship between a logical number and a physical number of each data packet stored in the current Nand flash block;
    根据所述逻辑号和所述映射表确定所述待读取数据包的物理号;Determining, according to the logical number and the mapping table, a physical number of the data packet to be read;
    读取确定的所述物理号对应物理页中的数据包。The determined physical number corresponds to the data packet in the physical page.
  3. 一种Nand flash的数据处理方法,其特征在于,应用于在所述Nand flash中指定的Nand flash块,所述Nand flash块中存储有预设格式的数据包; A Nand flash data processing method, which is applied to a Nand flash block specified in the Nand flash, where the Nand flash block stores a data packet in a preset format;
    所述Nand flash的数据处理方法包括:The Nand Flash data processing methods include:
    获取待修改数据包的修改指令以及待修改的数据;Obtaining a modification instruction of the data packet to be modified and data to be modified;
    根据所述修改指令确定所述待修改数据包的逻辑号;Determining, according to the modification instruction, a logical number of the data packet to be modified;
    根据最新数据包索引号读取当前Nand flash块的最新数据包,所述最新数据包索引号为所述当前Nand flash块中存储最新写入的数据包的物理页对应的物理号;Reading the latest data packet of the current Nand flash block according to the latest data packet index number, where the latest data packet index number is a physical number corresponding to the physical page of the current Nand flash block storing the newly written data packet;
    获取所述最新数据包中的映射表,所述映射表记录有所述当前Nand flash块中存储的各个数据包的逻辑号与物理号之间的映射关系;Obtaining, in the latest data packet, a mapping table, where the mapping table records a mapping relationship between a logical number and a physical number of each data packet stored in the current Nand flash block;
    根据所述逻辑号和所述映射表确定所述待修改数据包的物理号;Determining, according to the logical number and the mapping table, a physical number of the to-be-modified data packet;
    读取确定的所述物理号对应物理页中的数据包;Reading the determined physical number corresponding to the data packet in the physical page;
    将所述映射表中所述逻辑号对应的物理号更新为最新可用物理号,得到新的映射表,所述最新可用物理号为所述当前Nand flash块中最新的可用物理页对应的物理号;Updating the physical number corresponding to the logical number in the mapping table to the latest available physical number, to obtain a new mapping table, where the latest available physical number is the physical number corresponding to the latest available physical page in the current Nand flash block. ;
    采用所述待修改的数据修改读取的所述数据包中的数据;Modifying the data in the read data packet by using the data to be modified;
    根据修改后的数据和所述新的映射表生成新的数据包;Generating a new data packet according to the modified data and the new mapping table;
    将所述新的数据包写入所述最新可用物理号对应的物理页内。The new data packet is written into a physical page corresponding to the latest available physical number.
  4. 一种Nand flash的数据处理方法,其特征在于,应用于在所述Nand flash中指定的Nand flash块,所述Nand flash块中存储有预设格式的数据包; A Nand flash data processing method, which is applied to a Nand flash block specified in the Nand flash, where the Nand flash block stores a data packet in a preset format;
    所述Nand flash的数据处理方法包括:The Nand Flash data processing methods include:
    获取待删除数据包的删除指令;Obtaining a delete instruction of the data packet to be deleted;
    根据所述删除指令确定所述待删除数据包的逻辑号;Determining, according to the deleting instruction, a logical number of the to-be-deleted data packet;
    根据最新数据包索引号读取当前Nand flash块的最新数据包,所述最新数据包索引号为所述当前Nand flash块中存储最新写入的数据包的物理页对应的物理号;Reading the latest data packet of the current Nand flash block according to the latest data packet index number, where the latest data packet index number is a physical number corresponding to the physical page of the current Nand flash block storing the newly written data packet;
    获取所述最新数据包中的映射表,所述映射表记录有所述当前Nand flash块中存储的各个数据包的逻辑号与物理号之间的映射关系;Obtaining, in the latest data packet, a mapping table, where the mapping table records a mapping relationship between a logical number and a physical number of each data packet stored in the current Nand flash block;
    从所述映射表中删除所述逻辑号与对应的物理号之间的映射关系,得到新的映射表;And deleting a mapping relationship between the logical number and the corresponding physical number from the mapping table, to obtain a new mapping table;
    根据所述新的映射表生成新的数据包;Generating a new data packet according to the new mapping table;
    将所述新的数据包写入最新可用物理号对应的物理页内,所述最新可用物理号为所述当前Nand flash块中最新的可用物理页对应的物理号。The new data packet is written into a physical page corresponding to the latest available physical number, and the latest available physical number is a physical number corresponding to the latest available physical page in the current Nand flash block.
  5. 一种基于如权利要求1、3或4所述的Nand flash的数据处理方法的Nand flash块处理方法,所述Nand flash中设有由两个以上指定的Nand flash块组成的块循环池; A Nand flash block processing method based on the Nand flash data processing method according to claim 1, 3 or 4, wherein the Nand flash is provided with a block loop pool composed of two or more specified Nand flash blocks;
    在根据最新数据包索引号读取当前Nand flash块的最新数据包之前,所述Nand flash块处理方法包括:Before reading the latest data packet of the current Nand flash block according to the latest packet index number, the Nand flash block processing method includes:
    判断所述当前Nand flash块是否已满;Judging the current Nand Whether the flash block is full;
    若所述当前Nand flash块未满,则执行根据最新数据包索引号读取当前Nand flash块的最新数据包的步骤;If the current Nand If the flash block is not full, the step of reading the latest data packet of the current Nand flash block according to the latest packet index number is performed;
    若所述当前Nand flash块已满,则执行换块操作,然后执行根据最新数据包索引号读取当前Nand flash块的最新数据包的步骤;If the current Nand After the flash block is full, the block changing operation is performed, and then the step of reading the latest data packet of the current Nand flash block according to the latest packet index number is performed;
    所述换块操作具体包括以下步骤:The block changing operation specifically includes the following steps:
    擦除所述块循环池中的下一个Nand flash块;Erasing the next Nand flash block in the block loop pool;
    根据最新数据包索引号读取所述当前Nand flash块的最新数据包;Reading the latest data packet of the current Nand flash block according to the latest packet index number;
    获取所述最新数据包中的映射表;Obtaining a mapping table in the latest data packet;
    初始化第一逻辑号的值;Initializing the value of the first logical number;
    通过调整所述第一逻辑号的值依据所述映射表依次读取所述当前Nand flash块中的各个数据包,并将读取到的所述各个数据包依次写入所述下一个Nand flash块,直到所述当前Nand flash块中的各个数据包均写入至所述下一个Nand flash块;Reading each data packet in the current Nand flash block according to the mapping table by adjusting the value of the first logical number, and sequentially writing the read each data packet to the next Nand a flash block until each data packet in the current Nand flash block is written to the next Nand flash block;
    将所述下一个Nand flash块确定为当前Nand flash块。Will the next Nand The flash block is determined to be the current Nand flash block.
  6. 一种Nand flash的数据处理装置,其特征在于,应用于在所述Nand flash中指定的Nand flash块; A Nand flash data processing device, which is applied to a Nand flash block specified in the Nand flash;
    所述Nand flash的数据处理装置包括:The Nand The flash data processing device includes:
    写入数据获取模块,用于获取待写入数据;Writing a data acquisition module for acquiring data to be written;
    第一最新数据包读取模块,用于若所述待写入数据的数据量小于预设阈值,则根据最新数据包索引号读取当前Nand flash块的最新数据包,所述最新数据包索引号为所述当前Nand flash块中存储最新写入的数据包的物理页对应的物理号;a first latest data packet reading module, configured to: if the data volume of the data to be written is less than a preset threshold, read the latest data packet of the current Nand flash block according to the latest data packet index number, where the latest data packet index The number is a physical number corresponding to a physical page storing the latest written data packet in the current Nand flash block;
    第一映射表获取模块,用于获取所述最新数据包中的映射表,所述映射表记录有所述当前Nand flash块中存储的各个数据包的逻辑号与物理号之间的映射关系;a first mapping table obtaining module, configured to acquire a mapping table in the latest data packet, where the mapping table records a mapping relationship between a logical number and a physical number of each data packet stored in the current Nand flash block;
    映射关系建立模块,用于建立分配给所述待写入数据的逻辑号与最新可用物理号之间的映射关系,所述最新可用物理号为所述当前Nand flash块中最新的可用物理页对应的物理号;a mapping relationship establishing module, configured to establish a mapping relationship between the logical number assigned to the data to be written and the latest available physical number, where the latest available physical number is the latest available physical page in the current Nand flash block Physical number
    第一新映射表生成模块,用于将建立的所述映射关系添加至所述映射表中,生成新的映射表;a first new mapping table generating module, configured to add the established mapping relationship to the mapping table to generate a new mapping table;
    第一新数据包生成模块,用于根据所述新的映射表和所述待写入数据生成新的数据包;a first new data packet generating module, configured to generate a new data packet according to the new mapping table and the to-be-written data;
    第一写入模块,用于将所述新的数据包写入所述最新可用物理号对应的物理页内。The first writing module is configured to write the new data packet into a physical page corresponding to the latest available physical number.
  7. 一种Nand flash的数据处理装置,其特征在于,应用于在所述Nand flash中指定的Nand flash块,所述Nand flash块中存储有预设格式的数据包; A Nand flash data processing device is characterized in that it is applied to a Nand flash block specified in the Nand flash, and the Nand flash block stores a data packet in a preset format;
    所述Nand flash的数据处理装置包括:The Nand The flash data processing device includes:
    读取指令获取模块,用于获取待读取数据包的读取指令;a read instruction acquisition module, configured to acquire a read instruction of the data packet to be read;
    第一包号确定模块,用于根据所述读取指令确定所述待读取数据包的逻辑号;a first packet number determining module, configured to determine a logical number of the to-be-read data packet according to the read instruction;
    第二最新数据包读取模块,用于根据最新数据包索引号读取当前Nand flash块的最新数据包,所述最新数据包索引号为所述当前Nand flash块中存储最新写入的数据包的物理页对应的物理号;a second latest packet reading module, configured to read the latest data packet of the current Nand flash block according to the latest data packet index number, where the latest data packet index number is the latest data packet stored in the current Nand flash block The physical number corresponding to the physical page;
    第二映射表获取模块,用于获取所述最新数据包中的映射表,所述映射表记录有所述当前Nand flash块中存储的各个数据包的逻辑号与物理号之间的映射关系;a second mapping table obtaining module, configured to acquire a mapping table in the latest data packet, where the mapping table records a mapping relationship between a logical number and a physical number of each data packet stored in the current Nand flash block;
    第一物理号确定模块,用于根据所述逻辑号和所述映射表确定所述待读取数据包的物理号;a first physical number determining module, configured to determine, according to the logical number and the mapping table, a physical number of the to-be-read data packet;
    第一数据包读取单元,用于读取确定的所述物理号对应物理页中的数据包。And a first data packet reading unit, configured to read the determined data packet in the physical page corresponding to the physical number.
  8. 一种Nand flash的数据处理装置,其特征在于,应用于在所述Nand flash中指定的Nand flash块,所述Nand flash块中存储有预设格式的数据包; A Nand flash data processing device is characterized in that it is applied to a Nand flash block specified in the Nand flash, and the Nand flash block stores a data packet in a preset format;
    所述Nand flash的数据处理装置包括:The Nand The flash data processing device includes:
    修改指令获取模块,用于获取待修改数据包的修改指令以及待修改的数据;Modifying an instruction obtaining module, configured to acquire a modification instruction of the data packet to be modified and data to be modified;
    第二包号确定模块,用于根据所述修改指令确定所述待修改数据包的逻辑号;a second packet number determining module, configured to determine a logical number of the to-be-modified data packet according to the modification instruction;
    第三最新数据包读取模块,用于根据最新数据包索引号读取当前Nand flash块的最新数据包,所述最新数据包索引号为所述当前Nand flash块中存储最新写入的数据包的物理页对应的物理号;a third latest packet reading module, configured to read the latest data packet of the current Nand flash block according to the latest data packet index number, where the latest data packet index number is the latest data packet stored in the current Nand flash block The physical number corresponding to the physical page;
    第三映射表获取模块,用于获取所述最新数据包中的映射表,所述映射表记录有所述当前Nand flash块中存储的各个数据包的逻辑号与物理号之间的映射关系;a third mapping table obtaining module, configured to acquire a mapping table in the latest data packet, where the mapping table records a mapping relationship between a logical number and a physical number of each data packet stored in the current Nand flash block;
    第二物理号确定模块,用于根据所述逻辑号和所述映射表确定所述待修改数据包的物理号;a second physical number determining module, configured to determine a physical number of the to-be-modified data packet according to the logical number and the mapping table;
    第二数据包读取单元,用于读取确定的所述物理号对应物理页中的数据包;a second data packet reading unit, configured to read the determined data packet in the physical page corresponding to the physical number;
    第二新映射表生成模块,用于将所述映射表中所述逻辑号对应的物理号更新为最新可用物理号,得到新的映射表,所述最新可用物理号为所述当前Nand flash块中最新的可用物理页对应的物理号;a second new mapping table generating module, configured to update a physical number corresponding to the logical number in the mapping table to a latest available physical number, to obtain a new mapping table, where the latest available physical number is the current Nand flash block The physical number corresponding to the latest available physical page;
    数据修改模块,用于采用所述待修改的数据修改读取的所述数据包中的数据;a data modification module, configured to modify data in the read data packet by using the data to be modified;
    第二新数据包生成模块,用于根据修改后的数据和所述新的映射表生成新的数据包;a second new data packet generating module, configured to generate a new data packet according to the modified data and the new mapping table;
    第二写入模块,用于将所述新的数据包写入所述最新可用物理号对应的物理页内。And a second writing module, configured to write the new data packet into a physical page corresponding to the latest available physical number.
  9. 一种Nand flash的数据处理装置,其特征在于,应用于在所述Nand flash中指定的Nand flash块,所述Nand flash块中存储有预设格式的数据包; A Nand flash data processing device is characterized in that it is applied to a Nand flash block specified in the Nand flash, and the Nand flash block stores a data packet in a preset format;
    所述Nand flash的数据处理装置包括:The Nand The flash data processing device includes:
    删除指令获取模块,用于获取待删除数据包的删除指令;Deleting an instruction acquisition module, configured to acquire a deletion instruction of the data packet to be deleted;
    第三包号确定模块,用于根据所述删除指令确定所述待删除数据包的逻辑号;a third packet number determining module, configured to determine a logical number of the to-be-deleted data packet according to the deleting instruction;
    第四最新数据包读取模块,用于根据最新数据包索引号读取当前Nand flash块的最新数据包,所述最新数据包索引号为所述当前Nand flash块中存储最新写入的数据包的物理页对应的物理号;a fourth latest packet reading module, configured to read the latest data packet of the current Nand flash block according to the latest data packet index number, where the latest data packet index number is the latest data packet stored in the current Nand flash block The physical number corresponding to the physical page;
    第四映射表获取模块,用于获取所述最新数据包中的映射表,所述映射表记录有所述当前Nand flash块中存储的各个数据包的逻辑号与物理号之间的映射关系;a fourth mapping table obtaining module, configured to acquire a mapping table in the latest data packet, where the mapping table records a mapping relationship between a logical number and a physical number of each data packet stored in the current Nand flash block;
    第三新映射表生成模块,用于从所述映射表中删除所述逻辑号与对应的物理号之间的映射关系,得到新的映射表;a third new mapping table generating module, configured to delete a mapping relationship between the logical number and a corresponding physical number from the mapping table, to obtain a new mapping table;
    第三新数据包生成模块,用于根据所述新的映射表生成新的数据包;a third new data packet generating module, configured to generate a new data packet according to the new mapping table;
    第三写入模块,用于将所述新的数据包写入最新可用物理号对应的物理页内,所述最新可用物理号为所述当前Nand flash块中最新的可用物理页对应的物理号。a third write module, configured to write the new data packet into a physical page corresponding to a latest available physical number, where the latest available physical number is a physical number corresponding to the latest available physical page in the current Nand flash block .
  10. 一种Nand flash,其特征在于,包括如权利要求6至9中任意一项所述的Nand flash的数据处理装置。 A Nand flash characterized by comprising Nand according to any one of claims 6 to 9. Flash data processing device.
  11. 一种电子设备,其特征在于,包括:An electronic device, comprising:
    至少一个处理器;以及,At least one processor; and,
    与所述至少一个处理器通信连接的存储器;其中,a memory communicatively coupled to the at least one processor; wherein
    所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行权利要求1-5任一项所述的方法。The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the method of any of claims 1-5 method.
  12. 一种非易失性计算机可读存储介质,其特征在于,所述计算机可读存储介质存储有计算机可执行指令,所述计算机可执行指令用于使计算机执行权利要求1-5任一项所述的方法。A non-transitory computer readable storage medium, characterized in that the computer readable storage medium stores computer executable instructions for causing a computer to perform any of claims 1-5 The method described.
  13. 一种计算机程序产品,其特征在于,所述计算机程序产品包括存储在非易失性计算机可读存储介质上的计算机程序,所述计算机程序包括程序指令,当所述程序指令被计算机执行时,使所述计算机执行权利要求1-5任一项所述的方法。A computer program product, comprising: a computer program stored on a non-transitory computer readable storage medium, the computer program comprising program instructions, when the program instructions are executed by a computer, The computer is caused to perform the method of any of claims 1-5.
PCT/CN2017/116828 2017-03-17 2017-12-18 Data processing method and apparatus for nand flash, and nand flash WO2018166258A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710159938.1A CN107015764B (en) 2017-03-17 2017-03-17 Data processing method and device for Nand flash and Nand flash
CN201710159938.1 2017-03-17

Publications (1)

Publication Number Publication Date
WO2018166258A1 true WO2018166258A1 (en) 2018-09-20

Family

ID=59440336

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/116828 WO2018166258A1 (en) 2017-03-17 2017-12-18 Data processing method and apparatus for nand flash, and nand flash

Country Status (2)

Country Link
CN (1) CN107015764B (en)
WO (1) WO2018166258A1 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107015764B (en) * 2017-03-17 2020-03-27 深圳市江波龙电子股份有限公司 Data processing method and device for Nand flash and Nand flash
CN112997162A (en) * 2018-11-20 2021-06-18 华为技术有限公司 Method and device for deleting index entry in memory

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103955432A (en) * 2014-04-22 2014-07-30 深圳市硅格半导体有限公司 Data storage method and device
CN104778127A (en) * 2015-03-25 2015-07-15 合肥格易集成电路有限公司 Method and device for writing data by NAND FLASH
US20160048448A1 (en) * 2013-03-25 2016-02-18 Ajou University Industry-Academic Cooperation Foundation Method for mapping page address based on flash memory and system therefor
CN107015764A (en) * 2017-03-17 2017-08-04 深圳市江波龙电子有限公司 Nand flash data processing method, device and a kind of Nand flash

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7409489B2 (en) * 2005-08-03 2008-08-05 Sandisk Corporation Scheduling of reclaim operations in non-volatile memory
CN100477009C (en) * 2006-10-19 2009-04-08 骆建军 NAND FLASH memory device
CN100470506C (en) * 2007-06-08 2009-03-18 马彩艳 Flash memory management based on sector access
CN101676882B (en) * 2008-09-16 2013-01-16 美光科技公司 Built-in mapping message of memory device

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160048448A1 (en) * 2013-03-25 2016-02-18 Ajou University Industry-Academic Cooperation Foundation Method for mapping page address based on flash memory and system therefor
CN103955432A (en) * 2014-04-22 2014-07-30 深圳市硅格半导体有限公司 Data storage method and device
CN104778127A (en) * 2015-03-25 2015-07-15 合肥格易集成电路有限公司 Method and device for writing data by NAND FLASH
CN107015764A (en) * 2017-03-17 2017-08-04 深圳市江波龙电子有限公司 Nand flash data processing method, device and a kind of Nand flash

Also Published As

Publication number Publication date
CN107015764A (en) 2017-08-04
CN107015764B (en) 2020-03-27

Similar Documents

Publication Publication Date Title
US11573701B2 (en) Memory device and host device
JP6316974B2 (en) Flash memory compression
TWI306263B (en)
TW201118877A (en) Flash memory device, data storage system, and operation method of a data storage system
JP6608468B2 (en) Storage apparatus and control method thereof
EP3196767A1 (en) Method for writing data into flash memory device, flash memory device and storage system
CN110389709A (en) Sequential stream detection and data pre-head
CN111399750A (en) Flash memory data writing method and computer readable storage medium
CN113138945A (en) Data caching method, device, equipment and medium
WO2018166258A1 (en) Data processing method and apparatus for nand flash, and nand flash
CN109213450A (en) A kind of associated metadata delet method, device and equipment based on flash array
KR20100063495A (en) Semiconductor device comprising flash memory and address mapping method thereof
CN117331498A (en) Method, device, equipment and medium for constructing mapping table of solid state disk
CN114968838A (en) Data compression method and flash memory device
WO2022110172A1 (en) Data processing method and related device
WO2020039927A1 (en) Non-volatile storage device, host device, and data storage system
US11698871B2 (en) Method for PRP/SGL handling for out-of-order NVME controllers
EP3819771A1 (en) Data processing method and device, apparatus, and system
JP2020170477A (en) Storage device, control method thereof, and program
CN116301636B (en) Method for managing data structure and hardware accelerator based on hash algorithm
CN106557275B (en) A kind of method and device of data processing
CN111061683A (en) Method and device for storing and operating data stream at high speed
JP2014137749A (en) Storage device, write control method, and write control program
CN116360702A (en) Method, device, equipment and medium for optimizing aggregation big object writing flow

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17901248

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 17901248

Country of ref document: EP

Kind code of ref document: A1