CN113760781A - Data processing method and device, electronic equipment and storage medium - Google Patents

Data processing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN113760781A
CN113760781A CN202110244769.8A CN202110244769A CN113760781A CN 113760781 A CN113760781 A CN 113760781A CN 202110244769 A CN202110244769 A CN 202110244769A CN 113760781 A CN113760781 A CN 113760781A
Authority
CN
China
Prior art keywords
physical block
data
written
lookup table
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110244769.8A
Other languages
Chinese (zh)
Inventor
杜新杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Qianshi Technology Co Ltd
Original Assignee
Beijing Jingdong Qianshi Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Qianshi Technology Co Ltd filed Critical Beijing Jingdong Qianshi Technology Co Ltd
Priority to CN202110244769.8A priority Critical patent/CN113760781A/en
Publication of CN113760781A publication Critical patent/CN113760781A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/06Addressing a physical block of locations, e.g. base addressing, module addressing, memory dedication
    • G06F12/0646Configuration or reconfiguration
    • G06F12/0653Configuration or reconfiguration with centralised address assignment
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/10Address translation
    • G06F12/1009Address translation using page tables, e.g. page table structures

Abstract

The embodiment of the invention discloses a data processing method, a data processing device, electronic equipment and a storage medium, wherein the method comprises the following steps: according to a data request identifier in a received data writing request, determining a physical block address to be written, which is matched with the data request identifier, from a pre-established data storage lookup table; if the data are written in the physical block to be written corresponding to the block address of the physical block to be written, determining target data, and determining a target physical block for storing the target data from a preset idle lookup table; and writing the target data into the target physical block, updating the data storage lookup table and the idle lookup table according to the physical address to be written and the target physical address of the target physical block, and determining the physical block for storing the target data according to the updated data storage lookup table and the idle lookup table after receiving the data writing request. By the technical scheme of the embodiment of the invention, the technical effects of saving storage memory and improving the management efficiency of the physical block are realized.

Description

Data processing method and device, electronic equipment and storage medium
Technical Field
The embodiment of the invention relates to the technical field of computers, in particular to a data processing method and device, electronic equipment and a storage medium.
Background
NandFlash greatly reduces the cost of flash memory unit bit by reducing the process size and adopting a multi-level technology.
However, NandFlash also brings other problems, mainly manifested by degradation of device performance, such as decreased access speed, increased error rate, decreased endurance, and poor retention characteristics. Endurance refers to the maximum program and erase times (P/E Cycles) that a memory cell can withstand. The maximum number of erase/write operations is present because the program and erase operations of the flash memory are performed by electron tunneling, and a large amount of tunneling causes stress to the tunneling oxide layer, resulting in degradation of the electrical properties of the floating gate layer. Beyond a certain number of erasures, the memory cell loses its programming and erasing functions. These problems with multilevel technology and process size degradation place higher demands on flash memory management.
When the present invention is implemented based on the above-described embodiments, the inventors have found that the following problems occur:
at present, management of NandFlash's physical blocks is mostly realized through a plurality of tables, each table stores not only physical block information but also other associated information, when the storage capacity of a physical block increases, not only the number of tables increases, but also the associated content stored in the tables increases, and for example, Error Correction Code (ECC) and the like occupy a large amount of memory resources, for example: the NandFlash for managing 1MBytes needs a memory of 4KBytes, and at the moment, a controller with a relatively small memory cannot effectively manage the NandFlash, namely, the technical problem of inconvenient physical block management exists.
Disclosure of Invention
The invention provides a data processing method, a data processing device, electronic equipment and a storage medium, and aims to achieve the technical effects of saving storage memory and improving the management efficiency of physical blocks.
In a first aspect, an embodiment of the present invention provides a data processing method, where the method includes:
determining a physical block address to be written which is matched with a data request identifier from a pre-established data storage lookup table according to the data request identifier in the received data writing request;
if the data are written in the physical block to be written corresponding to the block address of the physical block to be written, determining target data, and determining a target physical block for storing the target data from a preset idle lookup table;
and writing the target data into the target physical block, updating the data storage lookup table and the idle lookup table according to the physical address to be written and the target physical address of the target physical block, and determining the physical block for storing the target data according to the updated data storage lookup table and the idle lookup table after receiving a data writing request.
In a second aspect, an embodiment of the present invention further provides a data processing apparatus, where the apparatus includes:
the device comprises a to-be-written physical block address determining module, a to-be-written physical block address determining module and a data storage searching table, wherein the to-be-written physical block address determining module is used for determining a to-be-written physical block address matched with a data request identifier from a pre-established data storage searching table according to the data request identifier in a received data writing request;
the target physical block determining module is used for determining target data if data are written in the physical block to be written corresponding to the physical block address to be written, and determining a target physical block for storing the target data from a preset idle lookup table;
and the table updating module is used for writing the target data into the target physical block, updating the data storage lookup table and the idle lookup table according to the physical address to be written and the target physical address of the target physical block, and determining the physical block for storing the target data according to the updated data storage lookup table and the idle lookup table after receiving a data writing request.
In a third aspect, an embodiment of the present invention further provides an electronic device, where the electronic device includes:
one or more processors;
a storage device for storing one or more programs,
when the one or more programs are executed by the one or more processors, the one or more processors implement the data processing method according to any one of the embodiments of the present invention.
In a fourth aspect, the embodiments of the present invention further provide a storage medium containing computer-executable instructions, which when executed by a computer processor, are used for executing the data processing method according to any one of the embodiments of the present invention.
According to the technical scheme of the embodiment of the invention, the physical block to be written is determined through the data request identifier, when the physical block to be written contains written data, target data is determined and written into the target physical block searched from the idle lookup table, meanwhile, the data storage lookup table and the idle lookup table are updated so that when the data writing request is received, the physical block can be determined based on the updated data storage lookup table and the idle lookup table, and then the data is written, so that the problem that a controller with a small memory cannot effectively manage each physical block is solved, the technical effects that only two tables are managed, the physical block utilization rate and the physical block management efficiency are improved are realized, and the controller can be suitable for various small memory controllers.
Drawings
In order to more clearly illustrate the technical solutions of the exemplary embodiments of the present invention, a brief description is given below of the drawings used in describing the embodiments. It should be clear that the described figures are only views of some of the embodiments of the invention to be described, not all, and that for a person skilled in the art, other figures can be derived from these figures without inventive effort.
Fig. 1 is a schematic flowchart of a data processing method according to an embodiment of the present invention;
fig. 2 is a flowchart illustrating a data processing method according to a second embodiment of the present invention;
fig. 3 is a schematic flowchart of a data processing method according to a third embodiment of the present invention;
fig. 4 is a schematic flowchart of a data processing method according to a fourth embodiment of the present invention;
fig. 5 is a schematic flowchart of a process of constructing a data storage lookup table and a free storage lookup table according to a fourth embodiment of the present invention;
fig. 6 is a schematic flow chart illustrating data reading according to a fourth embodiment of the present invention;
fig. 7 is a schematic structural diagram of a data processing apparatus according to a fifth embodiment of the present invention;
fig. 8 is a schematic structural diagram of an electronic device according to a sixth embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
Example one
Fig. 1 is a flowchart of a data processing method according to an embodiment of the present invention, where the embodiment is applicable to a case where physical blocks in a storage unit are allocated and managed, and the method may be executed by a data processing apparatus, where the apparatus may be implemented in the form of software and/or hardware, and the hardware may be an electronic device, or the like.
As shown in fig. 1, the method of this embodiment specifically includes the following steps:
s110, according to the data request identification in the received data writing request, determining the physical block address to be written matched with the data request identification from a pre-established data storage lookup table.
The data writing request can be an instruction or code for writing data, and the like, and is used for indicating that the data is written on a storage medium (such as a NandFlash chip). The data request identifier may be an identifier carried in the data write request, and may be a logical address of a physical block corresponding to the data to be written. The data storage lookup table may be predetermined and mainly determined according to the use condition of the physical block, and optionally, the data storage lookup table is used to manage the use state of the physical block to be used in the storage medium and is also used to store the corresponding relationship between the logical address and the physical address of the physical block. A physical block is a physical area on a storage medium where data is stored. The physical block address to be written may be a physical address corresponding to the data request identifier, that is, a physical address of a physical block to which data is to be written.
Specifically, when a data write request is received, a data request identifier carried in the data write request can be obtained by analyzing the data write request. Because the data request identifier is a logical address of the physical block, the physical address corresponding to the logical address can be found from the pre-established data storage lookup table, and the found physical address is used as the physical block address to be written.
And S120, if the data are written in the physical block to be written corresponding to the physical block address to be written, determining target data, and determining a target physical block for storing the target data from a preset idle lookup table.
The physical block to be written may be a physical block to which the physical block address to be written points. The target data may be all data currently stored in the physical block to be written and data to be written corresponding to the data write request. The free lookup table may be predetermined and mainly determined according to the usage of the physical block, and optionally, the free lookup table is used to manage the usage status of each spare physical block in the storage medium and is also used to record and manage the physical block in the free state, and the record content may include the physical address of the physical block in the free state. The target physical block may be a physical block in a free look-up table.
Specifically, after the physical block address to be written is determined, the physical block to be written may be found and the data in the physical block to be written may be detected. If the data is not written in the physical block to be written, the data to be written corresponding to the data writing request can be written in the physical block to be written. If the data is written in the physical block to be written, the data currently stored in the physical block to be written can be read, the data and the data to be written are integrated to be used as target data, and then the physical block corresponding to one physical block address can be randomly determined in the idle lookup table to be used as the target physical block for storing the target data.
S130, writing the target data into the target physical block, updating the data storage lookup table and the idle lookup table according to the physical address to be written and the target physical address of the target physical block, and determining the physical block for storing the target data according to the updated data storage lookup table and the idle lookup table after receiving the data writing request.
Wherein the target physical address may be a physical address of the target physical block.
Specifically, the target data is written into the target physical block according to the determined target physical address of the target physical block. Because the target physical block corresponding to the target physical address has stored the target data, the target physical block can be used to replace the physical block to be written, that is, the target physical address is updated to the data storage lookup table, the corresponding relationship between the target physical address and the logical address of the physical block to be written is established, and the related information of the target physical block is deleted from the idle lookup table. Because the data in the physical block to be written corresponding to the physical address to be written is already stored in the target physical block, the data in the physical block to be written can be erased, the physical block to be written is further recorded in the idle lookup table, and the related information of the physical block to be written is deleted from the data storage lookup table. And when the data storage lookup table and the idle lookup table are updated, the exchange between the physical block to be written and the target physical block is completed. After that, if a data write request is received, the physical block storing the target data may be determined according to the updated data storage lookup table and the idle lookup table.
It should be noted that, by using the data storage lookup table and the free lookup table, only two tables are needed when the storage medium (such as NandFlash) is managed. The sizes of the two tables depend on the size of the physical block, when the selected block (block) is the physical block, the NandFlash for managing 1Mbytes only needs a memory of 16bytes, and when the selected page (page) is the physical block, the NandFlash for managing 1Mbytes needs a memory of 512bytes, which is far smaller than other algorithms.
According to the technical scheme of the embodiment of the invention, the physical block to be written is determined through the data request identifier, when the physical block to be written contains written data, the target data is determined and written into the target physical block searched from the idle lookup table, and meanwhile, the data storage lookup table and the idle lookup table are updated, so that when the data writing request is received, the physical block is determined based on the updated data storage lookup table and the idle lookup table, and then the data is written, the problem that a controller with a small memory cannot effectively manage each physical block is solved, the technical effects that only two tables are used for management, the physical block management method can be suitable for various small memory controllers, and the utilization rate of the physical block and the management efficiency of the physical block are improved are achieved.
Example two
Fig. 2 is a schematic flow chart of a data processing method according to a second embodiment of the present invention, and in this embodiment, on the basis of the foregoing embodiments, reference may be made to the technical solution of this embodiment for a specific manner of determining a physical block and an update manner of a data storage lookup table and an idle lookup table. The same or corresponding terms as those in the above embodiments are not explained in detail herein.
As shown in fig. 2, the method of this embodiment specifically includes the following steps:
s210, according to the logical address to be written in the data request identifier, determining a physical block address to be written corresponding to the logical address to be written in from a pre-established data storage lookup table.
The logical address to be written may be a logical address corresponding to the data request identifier, and is used to determine a physical block to which data is to be written.
Specifically, the data request identifier may be determined as a logical address to be written into the physical block according to the received data request identifier. Furthermore, the logical address of the physical block to be written can be found from the pre-established data storage lookup table, the physical address corresponding to the logical address is determined, and the physical address is used as the physical block address to be written.
S220, if the data are written in the physical block to be written corresponding to the block address of the physical block to be written, determining target data, and determining a target physical block for storing the target data from a preset idle lookup table.
In order to quickly and accurately determine a target physical block for storing target data, the determination of the target physical block may be performed according to the following steps:
step one, if the storage data volume in the physical block to be written is larger than a preset data volume threshold value, determining that data are written in the physical block to be written.
Where the amount of data storage may be the current size in the physical block. The preset data amount threshold may be a threshold used for determining whether data is written in the physical block to be written, for example: the preset data amount threshold may be 0, 2bytes, or the like.
Specifically, the storage data size of the physical block to be written is obtained, and the storage data size is compared with a preset data size threshold. If the data storage amount is less than or equal to the preset data amount threshold, the physical block to be written is considered to be empty, that is, data is not written, and then the data can be directly written into the physical block to be written. If the data storage amount is greater than the preset data amount threshold, it may be considered that the physical block to be written is not empty, that is, data is written, and data cannot be directly written into the physical block to be written.
It should be noted that if data is written in the physical block to be written, the written data may be lost or damaged by writing data into the physical block.
And step two, determining target data according to the written data, the block attribute information stored in the sector spare area and the data to be written corresponding to the data writing request.
The physical block includes a sector spare area, and the sector spare area is used for storing block attribute information of the physical block. The written data is the data currently written in the physical block to be written. The sector spare area may be a sector reserved in a physical block for storing block attribute information. The block attribute information may include attribute information of the physical block itself, such as: the sequence number information (physical address information) previously assigned to the physical block may also include the sector status of the physical block, whether there is a corresponding logical address, and the like. The data to be written may be data corresponding to the data write request, that is, data to be written in the physical block.
Specifically, the written data of the physical block to be written and the block attribute information stored in the sector spare area are read, the written data and the block attribute information are integrated with the data to be written corresponding to the data writing request, and the integrated data are determined as target data.
And step three, determining a target physical block in which data is not written from a pre-established idle lookup table, so as to store the target data into the target physical block.
Specifically, the physical block to which data is not written may be determined to be a target physical block from a pre-established free lookup table, and the target data may be stored in the target physical block.
In an actual application process, there are cases where the physical blocks recorded in the free lookup table are usually unwritten physical blocks, but there may be a case where the physical blocks recorded in the free lookup table are damaged due to multiple uses or long-term non-use.
Optionally, if the target physical block is damaged, that is, the target physical block is a bad block, it may be considered that the target physical block cannot be used for storing data, and then a new target physical block may be determined through the following steps:
step one, if the target data is not written into the target physical block, marking the target physical block as a bad block, and removing the information of the target physical block from the idle lookup table.
Wherein the bad block is the damaged physical block.
Specifically, if the target data cannot be written into the target physical block, the target physical block may be considered to be damaged preliminarily, and at this time, the target physical block may be marked as a bad block. Because the target physical block can not be used for storing data, in order to ensure that the physical blocks recorded in the idle lookup table can be written with data, the information of the target physical block can be removed from the idle lookup table, which is beneficial to avoiding the problem that the target physical block is still called when the data is stored subsequently, and the target physical block is repeatedly confirmed to be a bad block, thereby causing time waste.
And step two, determining the target physical block for storing the target data from the idle lookup table again.
Specifically, a physical block is randomly determined to be a target physical block in the idle lookup table after the bad block is deleted, target data are stored in the target physical block, if the writing is successful, the subsequent operation of updating the table can be executed, and if the writing is failed, the step one is repeatedly executed until the target data are written into the target physical block or the idle lookup table is empty.
And S230, writing the target data into the target physical block, erasing the written data in the physical block to be written, and updating the information of the physical block to be written into the idle lookup table.
Specifically, writing the target data into the target physical block indicates that the written data has been transferred from the physical block to be written into the target physical block. Thus, written data to be written in the physical block can be erased. After the data is erased, the physical block to be written is empty, and the information of the physical block to be written can be updated into the idle lookup table.
S240, updating data in the data storage lookup table according to the target physical address of the target physical block, and updating the idle lookup table according to the block address to be written.
Specifically, since the written data and the data to be written are stored in the target physical block, the target physical block may be used to replace the physical block to be written. That is, the physical address of the physical block to be written in the data storage lookup table may be replaced with the physical address of the target physical block, that is, the corresponding relationship between the physical address of the target physical block and the logical address of the physical block to be written is established in the data storage lookup table, and the information related to the physical block to be written is deleted. In order to enable the physical block to be written to be reused, the physical block address to be written (the physical address of the physical block to be written) may be written into the free lookup table. And because the target physical block is already recorded in the data storage lookup table, the information corresponding to the target physical block in the idle lookup table can be deleted. At this point, the updating of the data storage look-up table and the free look-up table is completed.
According to the technical scheme of the embodiment of the invention, the physical address of the physical block to be written is determined according to the data storage lookup table through the logical address to be written in the data request identifier, when the physical block to be written contains written data, target data is determined and written into the target physical block searched from the idle lookup table, the physical block to be written is erased, the physical block to be written is updated into the idle lookup table, and the information of the target physical block is updated into the data storage lookup table.
EXAMPLE III
Fig. 3 is a schematic flow chart of a data processing method according to a third embodiment of the present invention, and in this embodiment, on the basis of the foregoing embodiments, reference may be made to the technical solution of this embodiment for the establishment manner of the data storage lookup table and the free lookup table. The same or corresponding terms as those in the above embodiments are not explained in detail herein.
As shown in fig. 3, the method of this embodiment specifically includes the following steps:
s310, establishing a data storage lookup table and an idle lookup table.
Specifically, when the storage medium is used for the first time, a data storage lookup table and a free lookup table may be configured for the storage medium. The physical block in the storage medium can also be detected, and the detected non-bad block is determined as the physical block to be recorded. The preset usage capacity in the storage medium, i.e. the number of physical blocks in the data storage look-up table, may be predetermined. And storing the physical address of the physical block to be recorded with the preset use capacity into a data lookup table, and establishing the corresponding relation between the physical address and the logical address. Further, the remaining physical blocks to be recorded are recorded in the free lookup table, which may be storing the physical addresses of the remaining physical blocks to be recorded in the free lookup table.
It should be noted that the preset usage capacity may be set according to actual usage requirements, and is not specifically limited in this embodiment. For example: 80% of the physical blocks to be recorded may be recorded in the data storage look-up table as the physical blocks with the preset use capacity, and the remaining 20% of the physical blocks to be recorded may be recorded in the free look-up table.
Optionally, the data storage lookup table and the free lookup table may be established according to the following steps:
step one, reading block attribute information of a sector spare area of each physical block.
It should be noted that, when the storage medium is used for the first time, the formatting process may be performed for each physical block. The formatting process comprises the following steps: and marking the bad block at the moment, and numbering the rest physical blocks except the bad block in sequence. The process of sequentially numbering physical blocks may be taken as a process of allocating physical addresses to physical blocks. Further, the physical address of the physical block may be stored as block attribute information in the sector spare area of the physical block.
Illustratively, the total number of physical blocks is 128, including 8 bad blocks, then the remaining physical blocks may be numbered sequentially from 1-120.
Specifically, the block attribute information of the sector spare area of each physical block is read, and the physical address corresponding to each physical block and the information whether the current physical block is a bad block are obtained.
And step two, reading each physical block according to the block attribute information, and writing the logical address of the current physical block into the block attribute information if the current physical block is determined not to be a bad block and is within the preset logical block capacity range according to the block attribute information.
The bad block may be a physical block that cannot be used for the first time the storage medium is used. The preset logical block capacity may be a preset usage number, which may be regarded as a preset number of physical blocks to which logical addresses are allocated.
Specifically, each physical block is read according to the block attribute information, if the block attribute information of the current physical block indicates that the current physical block is not a bad block and the number of the current physical block is less than or equal to the preset logical block capacity, it indicates that the current physical block is used for data storage, and a logical address can be allocated to the current physical block, and the allocated logical address is written in the block attribute information of the current physical block. And if the block attribute information of the current physical block indicates that the current physical block is not a bad block but the number of the current physical block is larger than the preset capacity of the logical block, the current physical block is used for idle storage and does not need to be allocated with a logical address.
It should be noted that, if the physical blocks are read from small to large according to the physical block numbers, if the current physical block address is equal to the preset logical block capacity, the subsequent physical blocks are all physical blocks used for idle storage.
And step three, determining the next physical block address of the current physical block, and determining whether the next physical block address exceeds the preset physical block capacity.
Wherein the preset physical block capacity may be a total number of physical blocks except for the bad block.
Specifically, the next physical block address of the current physical block is determined, and whether the next physical block address exceeds the preset physical block capacity is judged. If so, indicating that all the physical blocks have been traversed; if the physical block number is less than or equal to the preset value, the next physical block needs to be judged, and whether the logical address is allocated to the next physical block is determined until all the physical blocks are traversed.
And step four, establishing a data storage lookup table and an idle lookup table according to the determination result.
Wherein the determination result is whether the next physical block address exceeds the preset physical block capacity.
Specifically, if the determination result is that the next physical block address exceeds the preset physical block capacity, it indicates that traversal of all physical blocks which are not bad blocks is completed, and logical addresses are allocated to physical blocks within the logical block capacity range. And recording the physical blocks allocated with the logical addresses into a data storage lookup table, and establishing the corresponding relation between the allocated logical addresses and the physical addresses of the physical blocks in the table. Recording the physical blocks which are not bad blocks and are not allocated with the logical addresses into a free lookup table, and recording the physical addresses of the physical blocks in the table.
Optionally, the establishment of the data storage lookup table and the free lookup table may be completed according to the following steps:
and if the result is that the next physical block address exceeds the preset physical block capacity, determining the physical block generating the logical address according to the block attribute information of each physical block.
Specifically, if the next physical block address exceeds the preset physical block capacity, it indicates that the traversal of the physical block has been completed, the logical address has been allocated, and the physical block to which the logical address is not allocated can be used as the free storage. Further, the physical block for which the logical address has been generated can be specified from the block attribute information of each physical block.
And generating a data storage lookup table and an idle lookup table according to the logical address and the physical address of each physical block.
Specifically, the block attribute information in the physical block with the generated logical address is read, the physical address and the logical address of the physical block are obtained, and the physical address and the logical address are correspondingly stored in the data storage lookup table until all the physical blocks with the generated logical address are recorded in the data storage lookup table. Reading block attribute information in the physical block without generating the logical address, obtaining the physical address of the physical block, and storing the physical address into the idle lookup table until all the physical blocks without generating the logical address are recorded into the idle lookup table.
S320, according to the data request identification in the received data writing request, determining the physical block address to be written matched with the data request identification from a pre-established data storage lookup table.
S330, if the data are written in the physical block to be written corresponding to the physical block address to be written, determining the target data, and determining the target physical block for storing the target data from a preset idle lookup table.
S340, writing the target data into the target physical block, updating the data storage lookup table and the idle lookup table according to the physical address to be written and the target physical address of the target physical block, and determining the physical block for storing the target data according to the updated data storage lookup table and the idle lookup table after receiving the data writing request.
According to the technical scheme of the embodiment of the invention, the problem that a controller with a small memory cannot manage the storage space through a large number of data tables is solved by establishing the data storage lookup table and the idle lookup table, and the technical effects of saving the storage memory and improving the management efficiency of the physical block are achieved.
Example four
As an alternative implementation of the foregoing embodiments, fig. 4 is a schematic flow chart of a data processing method provided in the fourth embodiment of the present invention. The same or corresponding terms as those in the above embodiments are not explained in detail herein.
As shown in fig. 4, the method of this embodiment specifically includes the following steps:
after the data write request is obtained, the address of the physical block (to-be-written physical block) is obtained in the data storage lookup table, and the address data corresponding to the physical block, that is, the data stored in the physical block (written data), is read. And judging whether the data is clean or not according to the data stored in the physical block, namely judging whether the data is stored in the physical block or not.
And if the data is clean, directly writing the data to be written into the corresponding physical block. Further, whether the data to be written is successfully written is judged, if yes, the data to be written is written, and the process is ended; if not, marking the current physical block as a bad block, merging original data (written data, in this case, null) and data to be written in a storage medium (such as NandFlash) cache, randomly selecting a free physical block in a free storage lookup table (free lookup table), writing the data (target data) in the cache into the free physical block, judging whether the writing is successful, if so, erasing the data in the original dirty block (physical block to be written), updating the data storage lookup table and the free storage lookup table, and ending the process; if the writing fails, the processes of marking bad blocks, combining data, determining idle physical blocks and writing data are repeated until the writing is successful, the original dirty blocks are erased, the data storage lookup table and the idle storage lookup table are updated, and the process is ended.
If the data is not clean, that is, data is written in the physical block, the original data (written data, which is not empty in this case) and the data to be written in the storage medium cache can be merged in the storage medium cache, a free physical block is randomly selected from a free storage lookup table, the data in the cache is written in the free physical block, whether the writing is successful or not is judged, if the writing is successful, the process is ended, if the writing is failed, the bad block is repeatedly marked, the data is merged, and the processes of the free physical block and the data writing are determined until the writing is successful. After the write-in is successful, the physical block to be written in can be used as the original dirty block, the data in the original dirty block is erased, the data storage lookup table and the idle storage lookup table are updated, and the process is ended.
Fig. 5 is a schematic flowchart of a process of constructing a data storage lookup table and a free storage lookup table according to a fourth embodiment of the present invention. The same or corresponding terms as those in the above embodiments are not explained in detail herein.
As shown in fig. 5, the method of this embodiment specifically includes the following steps:
reading the spare area information (block attribute information stored in the sector spare area) of each physical block, judging whether an original factory marks a bad block according to the spare area information, if so, marking the bad block in the spare area of the physical block in sequence, and searching the next physical block address (adding one to the current physical block address); if not, further judging whether the physical block number of the current allocated logical block number (logical address) exceeds the logical block capacity (preset logical block capacity), if so, searching the next physical block address, if not, writing the logical block number in the spare area information of the current physical block, wherein the logical block number can be a continuous number, and searching the next physical block address.
After searching the next physical block address, judging whether the next physical block address exceeds the physical block capacity (preset physical block capacity) of the storage medium (such as flash), if not, returning to the step of reading the spare area information in the next physical block, if so, constructing a data storage lookup table and a free storage lookup table, and ending the process.
Fig. 6 is a schematic flow chart illustrating data reading according to a fourth embodiment of the present invention. The same or corresponding terms as those in the above embodiments are not explained in detail herein.
As shown in fig. 6, the method of this embodiment is: and determining the logical address of the physical block according to the data reading instruction, and searching the physical block address corresponding to the logical address in the data storage lookup table. Further, the data of the physical block may be read according to the physical block address and returned.
According to the technical scheme of the embodiment of the invention, the data storage lookup table and the idle storage lookup table are constructed to write data and read data, so that the problem that a controller with a small memory cannot rapidly and accurately manage the storage space through a large number of data tables is solved, the technical effects of saving the storage memory and improving the management efficiency of the physical block are achieved.
EXAMPLE five
Fig. 7 is a schematic structural diagram of a data processing apparatus according to a fifth embodiment of the present invention, where the apparatus includes: a to-be-written physical block address determining module 410, a target physical block determining module 420, and a table updating module 430.
The to-be-written physical block address determining module 410 is configured to determine, according to a data request identifier in a received data write request, a to-be-written physical block address matching the data request identifier from a pre-established data storage lookup table; a target physical block determining module 420, configured to determine target data if data has been written in a physical block to be written corresponding to the physical block address to be written, and determine a target physical block storing the target data from a pre-established idle lookup table; a table updating module 430, configured to write the target data into the target physical block, and update the data storage lookup table and the idle lookup table according to the physical address to be written and the target physical address of the target physical block, so that after a data write request is received, a physical block storing the target data is determined according to the updated data storage lookup table and the idle lookup table.
Optionally, the to-be-written physical block address determining module 410 is further configured to determine, according to the to-be-written logical address in the data request identifier, a to-be-written physical block address corresponding to the to-be-written logical address from a pre-established data storage lookup table.
Optionally, the target physical block determining module 420 is further configured to determine that data has been written into the physical block to be written if the amount of data stored in the physical block to be written is greater than a preset data amount threshold; determining target data according to the written data, block attribute information stored in the sector spare area and data to be written corresponding to the data writing request; the method comprises the steps that a physical block comprises a sector spare area, and the sector spare area is used for storing block attribute information of the physical block; determining a target physical block into which data is not written from a pre-established free lookup table to store the target data into the target physical block.
Optionally, the apparatus further comprises: and the data erasing module is used for erasing the written data in the physical block to be written so as to update the information of the physical block to be written into the idle lookup table.
Optionally, the table updating module 430 is further configured to update data in the data storage lookup table according to the target physical address of the target physical block, and update the idle lookup table according to the physical block address to be written.
Optionally, the apparatus further comprises: a target physical block re-determination module, configured to mark the target physical block as a bad block and remove information of the target physical block from the free lookup table if the target data is not written into the target physical block; and re-determining a target physical block for storing the target data from the free lookup table.
Optionally, the apparatus further comprises: the table establishing module is used for establishing the data storage lookup table and the idle lookup table; the table establishing module is specifically used for reading the block attribute information of the sector spare area of each physical block; reading each physical block according to the block attribute information, and if the current physical block is determined not to be a bad block and is within a preset logical block capacity range according to the block attribute information, writing a logical address of the current physical block into the block attribute information; determining the next physical block address of the current physical block, and determining whether the next physical block address exceeds the preset physical block capacity; and establishing the data storage lookup table and the idle lookup table according to the determination result.
Optionally, the table establishing module is further configured to determine, if the result indicates that the next physical block address exceeds the preset physical block capacity, a physical block for generating a logical address according to block attribute information of each physical block; and generating a data storage lookup table and an idle lookup table according to the logical address and the physical address of each physical block.
According to the technical scheme of the embodiment of the invention, the physical block to be written is determined through the data request identifier, when the physical block to be written contains written data, target data is determined and written into the target physical block searched from the idle lookup table, meanwhile, the data storage lookup table and the idle lookup table are updated so that when the data writing request is received, the physical block can be determined based on the updated data storage lookup table and the idle lookup table, and then the data is written, so that the problem that a controller with a small memory cannot effectively manage each physical block is solved, the technical effects that only two tables are managed, the physical block utilization rate and the physical block management efficiency are improved are realized, and the controller can be suitable for various small memory controllers.
The data processing device provided by the embodiment of the invention can execute the data processing method provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method.
It should be noted that, the units and modules included in the apparatus are merely divided according to functional logic, but are not limited to the above division as long as the corresponding functions can be implemented; in addition, specific names of the functional units are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the embodiment of the invention.
EXAMPLE six
Fig. 8 is a schematic structural diagram of an electronic device according to a sixth embodiment of the present invention. FIG. 8 illustrates a block diagram of an exemplary electronic device 50 suitable for use in implementing embodiments of the present invention. The electronic device 50 shown in fig. 8 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiment of the present invention.
As shown in fig. 8, electronic device 50 is embodied in the form of a general purpose computing device. The components of the electronic device 50 may include, but are not limited to: one or more processors or processing units 501, a system memory 502, and a bus 503 that couples the various system components (including the system memory 502 and the processing unit 501).
Bus 503 represents one or more of any of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, or a local bus using any of a variety of bus architectures. By way of example, such architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, micro-channel architecture (MAC) bus, enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
Electronic device 50 typically includes a variety of computer system readable media. Such media may be any available media that is accessible by electronic device 50 and includes both volatile and nonvolatile media, removable and non-removable media.
The system memory 502 may include computer system readable media in the form of volatile memory, such as Random Access Memory (RAM)504 and/or cache memory 505. The electronic device 50 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only, storage system 506 may be used to read from and write to non-removable, nonvolatile magnetic media (not shown in FIG. 8, and commonly referred to as a "hard drive"). Although not shown in FIG. 8, a magnetic disk drive for reading from and writing to a removable, nonvolatile magnetic disk (e.g., a "floppy disk") and an optical disk drive for reading from or writing to a removable, nonvolatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 503 by one or more data media interfaces. System memory 502 may include at least one program product having a set (e.g., at least one) of program modules that are configured to carry out the functions of embodiments of the invention.
A program/utility 508 having a set (at least one) of program modules 507 may be stored, for example, in system memory 502, such program modules 507 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which examples or some combination thereof may include an implementation of a network environment. Program modules 507 generally perform the functions and/or methodologies of embodiments of the invention as described herein.
The electronic device 50 may also communicate with one or more external devices 509 (e.g., keyboard, pointing device, display 510, etc.), with one or more devices that enable a user to interact with the electronic device 50, and/or with any devices (e.g., network card, modem, etc.) that enable the electronic device 50 to communicate with one or more other computing devices. Such communication may occur via input/output (I/O) interfaces 511. Also, the electronic device 50 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network, such as the Internet) via the network adapter 512. As shown, the network adapter 512 communicates with the other modules of the electronic device 50 over the bus 503. It should be appreciated that although not shown in FIG. 8, other hardware and/or software modules may be used in conjunction with electronic device 50, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.
The processing unit 501 executes various functional applications and data processing, for example, implementing a data processing method provided by an embodiment of the present invention, by executing a program stored in the system memory 502.
EXAMPLE seven
An embodiment of the present invention also provides a storage medium containing computer-executable instructions, which are used to perform a data processing method when executed by a computer processor.
The method comprises the following steps:
determining a physical block address to be written which is matched with a data request identifier from a pre-established data storage lookup table according to the data request identifier in the received data writing request;
if the data are written in the physical block to be written corresponding to the block address of the physical block to be written, determining target data, and determining a target physical block for storing the target data from a preset idle lookup table;
and writing the target data into the target physical block, updating the data storage lookup table and the idle lookup table according to the physical address to be written and the target physical address of the target physical block, and determining the physical block for storing the target data according to the updated data storage lookup table and the idle lookup table after receiving a data writing request.
Computer storage media for embodiments of the invention may employ any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for embodiments of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims (11)

1. A data processing method, comprising:
determining a physical block address to be written which is matched with a data request identifier from a pre-established data storage lookup table according to the data request identifier in the received data writing request;
if the data are written in the physical block to be written corresponding to the block address of the physical block to be written, determining target data, and determining a target physical block for storing the target data from a preset idle lookup table;
and writing the target data into the target physical block, updating the data storage lookup table and the idle lookup table according to the physical address to be written and the target physical address of the target physical block, and determining the physical block for storing the target data according to the updated data storage lookup table and the idle lookup table after receiving a data writing request.
2. The method according to claim 1, wherein the determining, according to a data request identifier in the received data write request, a physical block address to be written that matches the data request identifier from a pre-established data storage look-up table comprises:
and determining a physical block address to be written corresponding to the logical address to be written from a pre-established data storage lookup table according to the logical address to be written in the data request identifier.
3. The method according to claim 1, wherein determining target data if data is written in a physical block to be written corresponding to the physical block address to be written, and determining a target physical block storing the target data from a pre-established free lookup table comprises:
if the storage data amount in the physical block to be written is larger than a preset data amount threshold value, determining that data are written in the physical block to be written;
determining target data according to the written data, block attribute information stored in the sector spare area and data to be written corresponding to the data writing request; the method comprises the steps that a physical block comprises a sector spare area, and the sector spare area is used for storing block attribute information of the physical block;
determining a target physical block into which data is not written from a pre-established free lookup table to store the target data into the target physical block.
4. The method of claim 1, further comprising, after said writing said target data into said target physical block:
and erasing the written data in the physical block to be written so as to update the information of the physical block to be written into the idle lookup table.
5. The method of claim 1, wherein updating the data storage lookup table and the free lookup table according to the physical address to be written and the target physical address of the target physical block comprises:
and updating the data in the data storage lookup table according to the target physical address of the target physical block, and updating the idle lookup table according to the to-be-written physical block address.
6. The method of claim 1, further comprising:
if the target data is not written into the target physical block, marking the target physical block as a bad block, and removing the information of the target physical block from the free lookup table;
and re-determining a target physical block for storing the target data from the free lookup table.
7. The method of claim 1, further comprising:
establishing the data storage lookup table and the idle lookup table;
the establishing the data storage lookup table and the idle lookup table includes:
reading block attribute information of a sector spare area of each physical block;
reading each physical block according to the block attribute information, and if the current physical block is determined not to be a bad block and is within a preset logical block capacity range according to the block attribute information, writing a logical address of the current physical block into the block attribute information;
determining the next physical block address of the current physical block, and determining whether the next physical block address exceeds the preset physical block capacity;
and establishing the data storage lookup table and the idle lookup table according to the determination result.
8. The method of claim 7, wherein the building the data storage lookup table and the free lookup table according to the determination comprises:
if the result is that the next physical block address exceeds the preset physical block capacity, determining the physical block generating the logical address according to the block attribute information of each physical block;
and generating a data storage lookup table and an idle lookup table according to the logical address and the physical address of each physical block.
9. A data processing apparatus, comprising:
the device comprises a to-be-written physical block address determining module, a to-be-written physical block address determining module and a data storage searching table, wherein the to-be-written physical block address determining module is used for determining a to-be-written physical block address matched with a data request identifier from a pre-established data storage searching table according to the data request identifier in a received data writing request;
the target physical block determining module is used for determining target data if data are written in the physical block to be written corresponding to the physical block address to be written, and determining a target physical block for storing the target data from a preset idle lookup table;
and the table updating module is used for writing the target data into the target physical block, updating the data storage lookup table and the idle lookup table according to the physical address to be written and the target physical address of the target physical block, and determining the physical block for storing the target data according to the updated data storage lookup table and the idle lookup table after receiving a data writing request.
10. An electronic device, characterized in that the electronic device comprises:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement a data processing method as claimed in any one of claims 1-8.
11. A storage medium containing computer-executable instructions for performing the data processing method of any one of claims 1-8 when executed by a computer processor.
CN202110244769.8A 2021-03-05 2021-03-05 Data processing method and device, electronic equipment and storage medium Pending CN113760781A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110244769.8A CN113760781A (en) 2021-03-05 2021-03-05 Data processing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110244769.8A CN113760781A (en) 2021-03-05 2021-03-05 Data processing method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113760781A true CN113760781A (en) 2021-12-07

Family

ID=78786676

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110244769.8A Pending CN113760781A (en) 2021-03-05 2021-03-05 Data processing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113760781A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116304234A (en) * 2023-01-10 2023-06-23 奉加微电子(上海)有限公司 Data matching method, processing method, device, electronic equipment and storage medium

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110231594A1 (en) * 2009-08-31 2011-09-22 Hitachi, Ltd. Storage system having plurality of flash packages

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110231594A1 (en) * 2009-08-31 2011-09-22 Hitachi, Ltd. Storage system having plurality of flash packages

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116304234A (en) * 2023-01-10 2023-06-23 奉加微电子(上海)有限公司 Data matching method, processing method, device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
US7191306B2 (en) Flash memory, and flash memory access method and apparatus
US9684462B2 (en) Method and apparatus utilizing non-uniform hash functions for placing records in non-uniform access memory
US7461233B2 (en) Method for identifying data characteristics for flash memory
US8312204B2 (en) System and method for wear leveling in a data storage device
US8332576B2 (en) Data reading method for flash memory and controller and storage system using the same
EP2631916A1 (en) Data deletion method and device
US10922234B2 (en) Method and system for online recovery of logical-to-physical mapping table affected by noise sources in a solid state drive
US8874830B2 (en) Method for controlling memory array of flash memory, and flash memory using the same
KR20110001881A (en) Bit error threshold and remapping a memory device
CN110347613B (en) Method for realizing RAID in multi-tenant solid-state disk, controller and multi-tenant solid-state disk
US9009442B2 (en) Data writing method, memory controller and memory storage apparatus
CN115495025B (en) Method and device for managing abnormal memory block
CN110543435B (en) Mixed mapping operation method, device and equipment of storage unit and storage medium
CN103106148B (en) Block management method, storage controller and storage storing device
CN113760781A (en) Data processing method and device, electronic equipment and storage medium
US9778862B2 (en) Data storing method for preventing data losing during flush operation, memory control circuit unit and memory storage apparatus
CN111104347B (en) Heap memory block searching method, device, equipment and storage medium
US11803469B2 (en) Storing data in a log-structured format in a two-tier storage system
US11429519B2 (en) System and method for facilitating reduction of latency and mitigation of write amplification in a multi-tenancy storage drive
CN114546292A (en) Method and system for managing bad blocks of nand flash
US9128887B2 (en) Using a buffer to replace failed memory cells in a memory component
CN108614664A (en) Read error treating method and apparatus based on NANDflash
CN111026890A (en) Picture data storage method, system, device and storage medium based on index table
CN108052410B (en) Method and device for preventing errors of SPI-Nand read data page
US20170249093A1 (en) Storage method and distributed storage system

Legal Events

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